EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: peter900 on September 09, 2016, 09:22:18 AM



Title: Datagrid totals seem inconsistent with records displayed
Post by: peter900 on September 09, 2016, 09:22:18 AM

The screen shot below shows a datagrid with records 41 - 82 displayed ( with vertical scrolling ) yet the paging control at the bottom says Displaying 41 to 60 of 193 items   The 193 total is correct but why is the record range incorrect ?  Thanks.

https://www.dropbox.com/s/qns5zokjp3rji2t/eui09092016a.png?dl=0 (https://www.dropbox.com/s/qns5zokjp3rji2t/eui09092016a.png?dl=0)


Title: Re: Datagrid totals seem inconsistent with records displayed
Post by: jarry on September 10, 2016, 02:52:05 AM
Please look at this example http://code.reloado.com/alecay/edit#preview. It works fine.


Title: Re: Datagrid totals seem inconsistent with records displayed
Post by: peter900 on September 13, 2016, 12:12:19 AM
Thanks Jarry.  Sorry but I wasn't suggesting a code problem - like your example I have grids that display the correct totals.  Perhaps you or someone could look at the json which is driving the grid with the problems. It validates fine and I cannot see any issues.

https://www.dropbox.com/s/sweb527qme3xt4i/euiforumjson1.txt?dl=0 (https://www.dropbox.com/s/sweb527qme3xt4i/euiforumjson1.txt?dl=0)

Thanks.


Title: Re: Datagrid totals seem inconsistent with records displayed
Post by: iklotzko on September 13, 2016, 06:40:10 AM
Peter,

I noticed in your data the "Id" field is null in many--if not all--cases: this should be populated. Also, make sure you specify a value for the "idField", in your case it would read " idField: 'Id', ... "


If that doesn't solve your problems, can you please post relevant code AND post the request header you use to get the data shown.


Title: Re: Datagrid totals seem inconsistent with records displayed
Post by: peter900 on September 14, 2016, 02:07:16 AM
Thanks iklotzko - I'll look at filling the id field and then providing the identifier of the unique field in the JSON - like....

{"total":193,"idField: 'Id',"rows":[{"Id":"e778322rgy7","CreatedDate":"2016-08-28T14:43:45.000Z","Leader__c":".....

Thanks for your help on this.


Title: Re: Datagrid totals seem inconsistent with records displayed
Post by: iklotzko on September 14, 2016, 01:19:15 PM
Peter,

No problem! But, it's not in the returned results you want to specify the property: idField: 'Id'

You'll want this in the grid options itself, either through data-options property of your target element
Code:
<table class="easyui-datagrid" data-options="... idField: 'id', url: 'myurl.php'... " ..</table>

or if you use JavaScript to initialize your datagrid
Code:
$('#mygrid').datagrid({
   .
    idField: 'Id',
    url: 'myurl.php',
   .
   .
});

Please tell me if it works for you!
Ira


Title: Re: Datagrid totals seem inconsistent with records displayed
Post by: jarry on September 14, 2016, 07:49:42 PM
This example works fine.
http://code.reloado.com/alecay/2/edit#preview


Title: Re: Datagrid totals seem inconsistent with records displayed
Post by: iklotzko on September 15, 2016, 09:08:31 AM
Oh... Peter, are you actually using client side data or fetching from a URL?

I just tried this out in fiddle and the issue here is that it is a bit more complex for client pagination. You should check the examples out in the demo section of easyui.

Server-side pagination is considerably easier and consists mainly of determining which rows to bring back. Look at the examples.