jQuery UI Widgets › Forums › Grid › Incorrect rowdata Returned
This topic contains 4 replies, has 3 voices, and was last updated by FRE 11 years, 5 months ago.
-
Author
-
I am using the following method to retrieve the rowdata when a button on my site is pressed:
var rowindex = $('#sh_grid').jqxGrid('getselectedrowindex');var rowdata = $('#sh_grid').jqxGrid('getrenderedrowdata',rowindex);
However, I am experiencing some very odd problems… The ‘rowindex’ that is returned is always correct, but the ‘rowdata’ is incorrect if not on the first page.
My grid setup is this:
$("#sh_grid").jqxGrid({ width: 1196, altrows: true, source: dataAdapter, theme: 'metro', selectionmode: 'singlerow', sortable: true, pageable: true, autoheight: true, pagesize: 10, pagesizeoptions: [10,25,50,100], columnsresize: true, columns: [ { text: 'Shipment Reference', datafield: 'reference' }, { text: 'Shipment Date', datafield: 'date', align: 'center', cellsalign: 'center', cellsformat: 'dd-MMM-yyyy' }, { text: 'Contract No.', datafield: 'so_reference' }, { text: 'Goods Description', datafield: 'goods_description' }, { text: 'Total Base Value', datafield: 'total', align: 'right', cellsalign: 'right', cellsformat: 'c2' }, { text: 'Buyer Details', datafield: 'buyer_details' }, { text: 'Buyer Reference', datafield: 'buyer_reference' }, { text: 'Terms of Delivery', datafield: 'terms_of_delivery' }, { text: 'B/L Date', datafield: 'bol_date', align: 'center', cellsalign: 'center', cellsformat: 'dd-MMM-yyyy' }, { text: 'B/L No.', datafield: 'bol_number', align: 'right', cellsalign: 'right', } ]});
You will notice that my pagesize is 10, the following explains what happens to that:
On the first page, any row that is selected will return the correct index of that selected row, and it will also return the correct rowdata for that row.
However, as soon as you go to the next page and select another row, the returned rowindex is correct, but it returns the rowdata of the item one page ahead.
So to give an example:
If you are on page two and select a row of index 12, it will return the rowdata of rowindex + pagesize, so in this case will return the rowdata for 22.
Any ideas what could be causing this?
I think I have solve it by changing the following:
var rowindex = $('#sh_grid').jqxGrid('getselectedrowindex');var rowdata = $('#sh_grid').jqxGrid('getrenderedrowdata',rowindex);
to
var rowindex = $('#sh_grid').jqxGrid('getselectedrowindex');var rowdata = $('#sh_grid').jqxGrid('getrowdata',rowindex);
Why has this fixed my issue?
Hi,
I suppose that the reason is that the “rowindex” is bound index(index of a record in the data source) and the first method expects a visible index which is not necessary to be equal to the bound index especially when you have filtering, sorting or grouping applied.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi,
I have the same problem after use filterrow, Ids restart from 0 and when I try to getId or data I don’t have the goods row id/data.
var rowindex = $(“#tabListeTiers”).jqxGrid(‘getselectedrowindex’);
var dataRecord = $(“#tabListeTiers”).jqxGrid(‘getrowdata’, rowindex); //I get data from another row
var rowid = $(“#tabListeTiers”).jqxGrid(‘getrowid’, rowindex); //I get id from another rowwhen there is no filtering i don’t have this problem, but I use localrow filtering by enabling
filterable: true,
showfilterrow: true,If someone have a solution for my problem?
Best Regards,
I have just resolved my problem:
“getrowdata” works fine but not “getrowid”,
so I put my Id in data and I use “getrowdata” to get my Id and with local filtering works fine. -
AuthorPosts
You must be logged in to reply to this topic.