我有一个基于json数据更新的数据表,我正在秘密地更新该数据表,但问题是我必须将金额格式化为印度货币,例如27227004,我希望它的值为2,72,22,004



$(document).ready(function (){

    var table_data =
    	[
    	  [
    	    "CHEF BAKERS BROOKFIELD",
    	    "0",
    	    "2967629",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS ARAKERE",
    	    "0",
    	    "302542",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS AYYAPPA NGR",
    	    "0",
    	    "425433",
    	    "0"
    	  ],
    	  [
    	    "Chef Bakers Bellandur",
    	    "0",
    	    "1278244",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS BAGMANE CBP",
    	    "0",
    	    "546345",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS CHANDAPURA",
    	    "0",
    	    "167527",
    	    "0"
    	  ],
    	  [
    	    "Chef Bakers Doddanekkundi",
    	    "0",
    	    "490462",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS SIDDAPURA",
    	    "0",
    	    "461639",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS ECITY",
    	    "0",
    	    "699634",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS VYDEHI",
    	    "0",
    	    "459675",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS HARLUR ROAD",
    	    "0",
    	    "229458",
    	    "0"
    	  ],
    	  [
    	    "Chef Bakers Hennur Main Road",
    	    "0",
    	    "211808",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS HSR LAYOUT",
    	    "0",
    	    "806820",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS KADUBEESANAHALLI",
    	    "0",
    	    "1108619",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS COFFEE BOARD",
    	    "0",
    	    "774311",
    	    "0"
    	  ],
    	  [
    	    "Chef Bakers Kaggadasapura",
    	    "0",
    	    "280712",
    	    "0"
    	  ],
    	  [
    	    "Chef Bakers Koramangala",
    	    "0",
    	    "345426",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS KASAVANAHALLI",
    	    "0",
    	    "415546",
    	    "0"
    	  ],
    	  [
    	    "Chef Bakers Marathahalli 1",
    	    "0",
    	    "525344",
    	    "0"
    	  ],
    	  [
    	    "Chef bakers Marathahalli 2",
    	    "0",
    	    "507047",
    	    "0"
    	  ],
    	  [
    	    "Chef Bakers Mahadevapura",
    	    "0",
    	    "2518170",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS BEL LAYOUT",
    	    "0",
    	    "404171",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS MG ROAD",
    	    "0",
    	    "450749",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS MANYATA TECH PARK",
    	    "0",
    	    "428558",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS NAGAWARA",
    	    "0",
    	    "444891",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS PRESTIGE SHANTHINIKETAN",
    	    "0",
    	    "576911",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS PRITECH",
    	    "0",
    	    "1269371",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS RR NAGAR",
    	    "0",
    	    "566927",
    	    "0"
    	  ],
    	  [
    	    "Chef Bakers Kadugodi",
    	    "0",
    	    "1199501",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS SARJAPURA ROAD",
    	    "0",
    	    "457940",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS SINGASANDRA",
    	    "0",
    	    "245249",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS SPICE GARDEN",
    	    "0",
    	    "434369",
    	    "0"
    	  ],
    	  [
    	    "Chef Bakers Whitefield",
    	    "0",
    	    "1360325",
    	    "0"
    	  ],
    	  [
    	    "CHEF BAKERS YELAHANKA",
    	    "0",
    	    "1213855",
    	    "0"
    	  ]
    	]


    var table = $('#example').DataTable( {
        data: table_data,
        "scrollY": "200px",
	    "scrollCollapse": true,
    } );
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" rel="stylesheet"/>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<table id="example" class="table table-striped ">
    <thead>
        <tr>
            <th>Outlet</th>
            <th>MTD</th>
            <th>YTD</th>
            <th>Todays's Transaction</th>

        </tr>
    </thead>

</table>





我想要做的是将数字格式化为印度货币

请任何人有任何想法请指导我

最佳答案

我准备了具有印度语言环境的示例fiddle

var table = $('#example').DataTable({
    data: table_data,
    "scrollY": "200px",
    "scrollCollapse": true,
    "columnDefs": [{
      "targets": [2],
      "render": function(data, type, row) {
        return Number(data).toLocaleString('en-IN', {
          maximumFractionDigits: 2,
          style: 'currency',
          currency: 'INR'
        });
      }
    }]
  });

关于javascript - 如何使用javascript/jquery将数字格式化为印度货币(在数据表中),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53373234/

10-12 03:37