how to format weights in boostrap?

0

this is the code with the table showing

                <table  id="table2" ng-init="loadData()"data-height="430"  data-click-to-select="true"data-search="true">
                      <thead>
                        <tr>

                                <th data-field="statusAut" data-checkbox="true" data-formatter="stateFormatter"></th>
                                <th data-field="idCompra">IDCOMP</th>
                                <th data-field="CveSuc">CLIENTE</th>
                                <th data-field="NoOrden">ORDEN-COMP</th>
                                <th data-field="NomProv">PROVEEDOR</th>
                                <th data-field="TotalPed" data-formatter="priceFormatter">TOTAL COMPRA</th>
                                <th data-field="FalltaPed">FECHA PEDIDO</th>
                                <th data-field="NumUser" >USUARIO</th>
                                <th data-field="FechHoraAut">FECHA Y HORA AUT.</th>
                        </tr>
                        </thead>
                        </table>
        </div>
    </div>
</div>
</div>
    </div>
<!-- FIN CONTROLLER -->
<script src="<?php echo base_url(); ?>bootstrap/js/ui-grid.min.js"></script>
<script>
        $('#table2').on('check.bs.table', function (e, row) {
        angular.element($('#requisicionID')).scope().aprobar(row);
});
  function stateFormatter(value, row, index) {
     if (value === 'Autorizada') {
         return {
             disabled: true,
             checked: true
         }
     }
     return value;
 }
     function priceFormatter(value) {
    // 16777215 == ffffff in decimal
    var color = '#'+Math.floor(Math.random() * 6776566161616).toString(18);
    return '<div  style="color: ' + color + '">' +
                    '<i class="glyphicon glyphicon-usd"></i>' +
                    value.substring(0) +
                    '</div>';

}     

and that's how it looks.

What I want is to be separated by commas example (1,400,000.00), if someone could help me I would appreciate it very much.

    
asked by sonjer 15.12.2016 в 22:55
source

1 answer

2

Try this, you change the toLocaleString to the number

$('.number').each(function(){
  console.log($(this).text());
  var number = parseFloat($(this).text());
  $(this).text("$"+number.toLocaleString(['ban','id']));
  $(this).css('background','red');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input class="numero" value="5000.78"></span>
<table id="mytable">
  <tr>
<th>Customer Id</th>
<th>Result</th>
  </tr>
  <tr>
<td class="number">5000.76</td>
<td></td>
  </tr>
  <tr>
<td class="number">7654234.76</td>
<td></td>
  </tr>
  <tr>
<td class="number">7890.44</td>
<td></td>
  </tr>
</table>
    
answered by 15.12.2016 / 23:14
source