EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Aod47 on July 30, 2016, 03:25:45 AM



Title: json data for datagrid -- can I change the word total & rows
Post by: Aod47 on July 30, 2016, 03:25:45 AM
Hello,

Because sometimes. I got json data from cross server that not use total, rows for datagrid paging eg. results_count for total,
and results for rows the example file structure below.

{
  "code" : 1,
  "results_count": 10,
  "results" : [
      "col1" : 001,
      "col2" : xxxx

.................

So, how do I use json data directly with easyui datagrid?

Thank you for helping





Title: Re: json data for datagrid -- can I change the word total & rows
Post by: jarry on July 30, 2016, 05:21:55 PM
Please use 'loadFilter' to convert the original data to the desired data format.
Code:
$('#dg').datagrid({
  loadFilter: function(data){
    return {
      total: data.results_count,
      rows: data.results
    };
  }
});