Bootstrap Table Format Numbers With Comma And Decimal Places In ASP.NET MVC
Hello and Good Evening.
Here's how to format numbers with comma and decimal places in Bootstrap Table columns by Wenzhixin using data-formatter tag. Simple set the data-formatter property of the tag.
And the JavaScript code to format those numbers use only toLocaleString() function with parameters set for minimum and maximum fraction digits.
Output
Sample Fiddle: Bootstrap Table Format Numbers With Comma And Decimal Places
Here's how to format numbers with comma and decimal places in Bootstrap Table columns by Wenzhixin using data-formatter tag. Simple set the data-formatter property of the
<table id="tblBilling" data-toggle="table" data-search="true" data-advanced-search="true" data-id-table="billingTable" data-show-export="true" data-toolbar="#toolbar1" data-click-to-select="true" data-height="500" data-url='@Url.Action("GetBillingInformation", "BillingDashboard")' data-cookie-id-table="tblBillableID"> <thead> <tr style="background-color: #FFFFFF;"> <td data-field="CustomerID" data-sortable="false" data-searchable="false" data-visible="false">Customer ID</td> <td data-field="CustomerName" data-sortable="false" data-searchable="false" data-visible="false">Customer Name</td> <th data-field="Address" data-sortable="true" data-searchable="true">Address</th> <th data-field="Price" data-sortable="true" data-formatter="NumFormatter" data-searchable="true">Price</th> <th data-field="TotalAmount" data-sortable="true" data-formatter="NumFormatter" data-searchable="true">Total Amount</th> </tr> </thead> </table>
function NumFormatter (data) { return parseFloat(data).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 }); };
Sample Fiddle: Bootstrap Table Format Numbers With Comma And Decimal Places
Comments
Post a Comment