JQuery.BootGrid data types and data formatters

pashute picture pashute · Aug 14, 2015 · Viewed 7k times · Source

What data types and data formatters are available with JQuery.BootGrid? Or are the data-type and data-formatter fields actutally JQuery DataTypes or some other property? If so what are the JQuery DataTypes? (I couldn't find documentation about that)

I want to set a column as currency (with a dollar sign to the left), how do I do that with JQuery.BootGrid?

But I want to understand the data-type/data-formatter in general. Do I have to understand jqGrid formatter for that, or is bootGrid a totally different product?

Answer

Abdul Manaf Saparuddin picture Abdul Manaf Saparuddin · Mar 19, 2017

Actually I've been using jquery bootgrid for the last 8 months and Using its formatter function to reformat any columns.

In the js file:

$("#grid").bootgrid({
  money: function(column, row) {
    return '$ '+row[column.id];
  },
  priceFormat: function(column, row) {
    return '<span class="price-format">'+row[column.id]+'</span>';
  }
});    

In the html:

<thead>
  <tr>
    <th data-column-id="id" data-identifier="true" data-type="numeric">ID</th>
    <th data-column-id="nama">Nama</th>
    <th data-column-id="merk">Merk</th>
    <th data-column-id="harga_limit" data-formatter="money">Harga Limit</th>
    <th data-column-id="harga_satuan" data-formatter="money">Harga Satuan</th>
    <th data-column-id="harga_total" data-formatter="priceFormat">Total</th>
  <tr>
</thead>