jQuery UI Widgets › Forums › Grid › Finding all selected cells in the grid
Tagged: grid, grid control
This topic contains 9 replies, has 3 voices, and was last updated by ragavsrini 5 years, 10 months ago.
-
Author
-
Hi All,
First i would like you to thank the jqxwidgets team for making the code freely available. It is a boon for developers like me đ
I am able to generate the grid and have enabled the ‘multiplecellsextended’ selection mode.
The issue is that I am not able to find all the selected cells. I simply want to know the column and row number of ALL the cells selected.
I checked the code for the grid using firebug and did not find any ID associated with the cell DIV.
Please help me resolve this issue!
Thank You
Hi amankejriwal,
Thanks for writing.
Regarding your question:
To get the selected cells, you may use the Grid’s “getselectedcells” method which returns an Array of the selected cells.
var cells = $('#grid').jqxGrid('getselectedcells');
Each cell has rowindex and datafield fields. The rowindex is the row’s index and the datafield is the column’s datafield.
Regarding the license terms and conditions, please take a look at: http://www.jqwidgets.com/license and EULA.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
Thank you for your response!
I wrote the following code:
$(“#jqxgrid”).on(‘cellselect’, function (event) {
var cells = $(“#jqxgrid”).jqxGrid(‘getselectedcells’, event.args.datafield);
alert(cells);
});This returns the following: [object Object]
How can I see the contents of this object?
Regards
AmanI changed the code to:
$(â#jqxgridâ).on(âcellselectâ, function (event) {
var cells = $(â#jqxgridâ).jqxGrid(âgetselectedcellsâ);
alert(cells);
});Now it is giving back all the selected cells as [object Object], [object Object], [object Object], ……..
Again, how do i see the contents of these objects?
Hi amankejriwal,
To get the cell’s value, you can use this:
var rowindex = 0;var datafield = "firstname";var value = $("#grid").jqxGrid('getcellvalue', rowindex, datafield);
Each object in the getselectedcells array have rowindex and datafield options and you can use them to retrieve the cell’s value.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
Actually I am trying to ask if it is possible to get the datafields and rowindexes of ALL the selected cells in an array? Do we have a function for that?
Also, is there a list of functions for the grid javascript that I can reference?
Regards
AmanHi Aman,
Yes, that is the “getselectedcells” method. It returns all selected cells as an Array. Each cell in the Array have rowindex and datafield.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
I do get an array but am not able to access it’s contents.
Any idea on how to do that?
Regards
AmanHey Peter,
I got it……thank you!!
Regards
AmanHi amankejriwal,
Could you please share code to find rowindex from selected cells.
Thanks
Srini -
AuthorPosts
You must be logged in to reply to this topic.