jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Losing a row
Tagged: #jqwidgets-grid, grid, javascript grid, jquery grid
This topic contains 7 replies, has 2 voices, and was last updated by Pietervk 8 years, 1 month ago.
-
AuthorLosing a row Posts
-
Hi, I have a grid in virtual mode that loses a row. So instead of 10 rows, it consistently removes one row, and only shows 9 with the last row blank. This only happens on particular set of data, I have not seen it on other data.
On LoadComplete, I have a “records” object, with 10 rows, with object number 6 that has the data that is later lost.
On the grid create call:
` $(“.jqxgrid”).jqxGrid(
{
source: dataAdapter,
width: StWidth,
pageable: true,
pagesize: pagesize,
sortable: true,
filterable: true,
enabletooltips: true,
columnsresize: true,
columnsautoresize: true,
pagesizeoptions: [‘5′, ’10’, ’20’, ’30’],
autoheight: true,
theme: ‘energyblue’,
columns: StColumns,
virtualmode: true,
rendergridrows: function (params) {
return params.data;
},})`
params.data contains only 9 records, 0 to 9, with startindex 0 and endindex 10.
Any idea how this can occur?
Thanks, Pieter
PS, I have added 4 rows, so now my row 6 that was lost is the 10th row. It shows on the second page as normal. However, when I change the page size to 20, the row disappears again!
Hello Pietervk,
You should add the new row to the backend and also implement
addrow
callback.
It is normal to disappear some row when you use ‘virtualmode’ and it is not in the database because when changing the page the Grid is repainted.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comHi Hristo,
sorry if my post was not clear.All rows are retrieved from the database and filtered, then on loadcomplete, all rows are still there. However in the rendergridrows function, one row has disappeared. So with all rows in the database, one gets lost after loadcomplete and before it is displayed, by the processing that is done in the grid.
Thanks for looking in to this again.
Pieter
Hello Pieter,
I would suggest you check again is the new rows are in the database after addrow method.
This is a strange behavior.
Could you provide the whole code – the DataAdapter’s source, the DataAdapter?Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comHello Hristo,
They are in the database. The row was already missing in the grid before adding the row. I am adding the row in the database, I am not using the addrow method. But please do not focus on adding the row. All data is there on loadComplete, it is lost when rendergridrows is called.
Here is most of the code:source = { datatype: "json", datafields: [ { name: 'ClientLabel', type: 'string' }, { name: 'SessionId', type: 'string' }, { name: 'TestId', type: 'string' }, { name: 'DtCreated', type: 'date', format: 'yyyy-MM-dd HH:mm' }, { name: 'DtFirstLogin', type: 'date', format: 'yyyy-MM-dd HH:mm' }, { name: 'DtLastSaved', type: 'date', format: 'yyyy-MM-dd HH:mm' }, { name: 'Aq', type: 'string' }, { name: 'Finished', type: 'bool' }, { name: 'ReminderNeeded', type: 'int' }, { name: 'Id', type: 'int' }, { name: 'IntID', type: 'int' }, { name: 'RepSent', type: 'bool' }, ], async: true, id: 'Id', cache: false, type: "GET", root: 'Tests', url: 'GetTests', formatData: function (data) { data = JSON.stringify(data); return { "jsonData": data }; }, beforeprocessing: function (data) { source.totalrecords = data.TotalRecords; }, sort: function (data) { $('#jqxgrid').jqxGrid('updatebounddata', 'sort'); }, filter: function (data) { $('#jqxgrid').jqxGrid('updatebounddata', 'filter'); } }; dataAdapter = new $.jqx.dataAdapter(source, { contentType: 'application/json; charset=utf-8', autoBind: false, loadComplete: function (records) { //inspecting records here shows all records }, } ); $('#jqxgrid').on("bindingcomplete", function (event) { StatusGridDone = true; clearTimeout(refreshTim); refreshTim = setTimeout(refreshStatusGrid, 15000); }); $(".jqxgrid").jqxGrid( { source: dataAdapter, width: StWidth, pageable: true, pagesize: pagesize, sortable: true, filterable: true, enabletooltips: true, columnsresize: true, columnsautoresize: true, pagesizeoptions: ['5', '10', '20', '30'], autoheight: true, theme: 'energyblue', columns: StColumns, virtualmode: true, rendergridrows: function (params) { return params.data; //row is gone here }, }); function refreshStatusGrid() { if (StatusGridDone) { updateStatusGrid(); } clearTimeout(refreshTim); refreshTim = setTimeout(refreshStatusGrid, 15000); } function updateStatusGrid() { if ($('#jqxgrid').is(":visible")) { $('#jqxgrid').source = dataAdapter; dataAdapter.dataBind(); $('#jqxgrid').jqxGrid("updatebounddata", "cells"); } else { clearTimeout(refreshTim); } }
Thanks, Pieter
Hello Pieter,
I would like to suggest you look at this demo:
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/createremoveupdatedata.htm?light
When you add, update or delete an item you should implement relevant callbacks withcommit(true)
when you want these changes or false if you do not want them.If all rows are in the database and all settings are on the right way implemented you do not need to refresh data (DataAdapter).
When you change page (or page size) this invokesrendergridrows
callback function. (and in the same time you use setTimeout)Also, I would like to say “$(‘#jqxgrid’).source = dataAdapter;” it is not correct, it should be
$('#jqxgrid').jqxGrid({ source: dataAdapter });
But this is not necessary if the implementation is correct.
Another thing – it is better to use$('#jqxgrid').jqxGrid({...})
instead of “$(“.jqxgrid”).jqxGrid” in the initialization.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comHi Hristo,
Thank you for the tips, I have implemented these.Pieter
-
AuthorPosts
You must be logged in to reply to this topic.