gpt4 book ai didi

javascript - 如何使用 javascript/jquery 将数字格式化为印度货币(在数据表中)

转载 作者:行者123 更新时间:2023-12-01 01:29:58 26 4
gpt4 key购买 nike

我有一个基于 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>

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

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

最佳答案

我准备了 sample 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com