jQuery UI Widgets › Forums › Grid › Grid column details from selected row
Tagged: column, getrowdata, getselectedrowindex, grid, jqxgrid, row
This topic contains 5 replies, has 3 voices, and was last updated by JMS786 12 years, 4 months ago.
-
Author
-
Hi ,
Is there a way to get column details from the selected row?
The following code gets rowindex.
var rowindex = $(gridName).jqxGrid(‘getselectedrowindex’);
Is there a similar kind of API to get column details from the row’s cell that we have selected.
Thanks,
KishoreHello Kishore,
When you have the selected row’s index, you can use it in the method getrowdata to get the desired column information.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar,
Thanks for your reply. Can you show me a sample code which does that,or a demo which can help me.
thanks,
KishoreIs there a way to get column name or index from the cell that we have selected,with out binding cellselect event.
Thanks,
KishoreHi Kishore,
1) Here is a sample code:
var rowindex = $(gridName).jqxGrid(‘getselectedrowindex’);var data = $('#jqxGrid').jqxGrid('getrowdata', rowindex);The fields of the data object contain the column values.
2) Here is an example on the cellselect event:
$("#jqxGrid").on('cellselect', function (event) { var columnheader = $("#jqxGrid").jqxGrid('getcolumn', event.args.datafield).text; var rowindex = event.args.rowindex;});
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar,
I have similar problem, but when i apply your code, especially in this line
var columnheader = $("#jqxGrid").jqxGrid('getcolumn', event.args.datafield).text;
I get an error :
Uncaught TypeError: Cannot read property ‘datafield’ of undefined.I have tried to copy the code, but the different is i use the grid as an input tool, therefore my grid does not have source:dataAdapter.
Do you think the absence of source:dataAdapter is the main problem or that should be no problem?
If no problem how do I fix the ‘datafield’ error.
Thanks,
JMS -
AuthorPosts
You must be logged in to reply to this topic.