jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Problem with grouping on last page
Tagged: datagridview control, datagridview grouping, jqxgrid
This topic contains 2 replies, has 2 voices, and was last updated by morgar 11 years, 9 months ago.
-
Author
-
Hi. I have a grid that is ordered, paged and sorted on the server. Everything seems to work fine, but when I group the rows, in the last page a group is added. This group is filled with empty rows in order to complete the current page size. So, if the page size is 100 and the last page has only 54 rows, a group with 46 empty rows is added. See pict http://blixflow.supplest.com/grouping_error.jpg
Am I missing something?
This is my code:
<script type="text/javascript"> $(function() { var source = { datatype: "json", datafields: [ { name: 'sale_id', type: 'string' }, { name: 'id', type: 'string' }, { name: 'product', type: 'string' }, { name: 'quantity', type: 'int' }, { name: 'total_sqft', type: 'number' }, { name: 'product_total', type: 'number' }, { name: 'status', type: 'string' } ], id: 'id', url: url_data, root: 'rows', cache: false, sort: function() { $("#jqxgrid").jqxGrid('updatebounddata', 'sort'); }, filter: function() { $("#jqxgrid").jqxGrid('updatebounddata', 'filter'); }, beforeprocessing: function(data) { source.totalrecords = data.row_count; } }; var data_adapter = new $.jqx.dataAdapter(source); $("#jqxgrid").jqxGrid({ width: width, height: 640, theme: 'metro', columnsresize: true, sortable: true, showsortcolumnbackground: false, filterable: true, pageable: true, pagesizeoptions: ['50', '100', '200'], groupable: true, virtualmode: true, source: data_adapter, rendergridrows: function() { return data_adapter.records; }, columns: [ { text: '', width: 60 }, { text: 'Order', datafield: 'sale_id', width: 80, cellsalign: 'center' }, { text: 'ID', datafield: 'id', width: 80, cellsalign: 'center' }, { text: 'Product', datafield: 'product', width: 280, }, { text: 'Quantity', datafield: 'quantity', width: 90, cellsalign: 'right' }, { text: 'SqFt', datafield: 'total_sqft', width: 90, cellsalign: 'right', cellsformat: 'f2' }, { text: 'Total', datafield: 'product_total', width: 90, cellsalign: 'right', cellsformat: 'c2' }, { text: 'Status', datafield: 'status', minwidth: 120 } ] }); });</script>
Hi morgar,
That is how grouping in Virtual mode currently works. The “rendergridrows” expects to return the records for the displayed page depending on the passed parameters. If the Grid expects records from 10 to 20 and you return records from 10 to 15, the rest of the records will be empty.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi Peter,
Not sure if I understand. The data sourse include the TotalRows value, so the grid knows that the last page include only 54 rows and not 100 (in this case), and that’s rendered properly when the grid is not grouped,
BTW, I didn’t say it before, but I think you made an oustanding job with these components.
Regards
morgar -
AuthorPosts
You must be logged in to reply to this topic.