Reading cell values client-side

Dumb question, if I may?

Is it possible to in client side Javascript to get hold of the value of a specific cell. For example, if I wanted the contents of first cell of row 5?

I know you can get row data in client side event functions such as OnRecordSelectionEvent, but this only the row that has been clicked.

If I, say, want to then look at all the other selected rows in the same function, can I do that? I can see which rows are selected via gridObj._selectionManager.selectedRowsCollection, but how would I get their cell contents?

Thanks
Mark


5 Replies

BM Bala Murugan A.S Syncfusion Team February 21, 2012 06:46 AM UTC

Hi Mark,

Thanks for using Syncfusion Products.

We glad to inform you that we have achieved your requirement. Please refer the below code snippet.

[javascript]

gridObj = $find("Grid1");
//Selected Row's object
var selectedRows = gridObj.selectedRows();

/*here you can get any selected row's cell value from selectedRows object (gridObj.selectedRows()) collection by specifying the rowIndex and cellIndex.*/
//0 -rowIndex, 5-cellIndex
var value = selectedRows[0].cells[5].innerHTML;



For your convenience, we have prepared a simple sample to demonstrate this and same can be downloaded from the below link.

SelectedRows1395894463.zip

Note: selectedRowsCollection gives only the array of indexes of the selected rows.

Please try the above sample and let us know if you need further assistance.

Regards,
Bala Murugan A.S



MT Mark Treveil February 21, 2012 10:23 AM UTC

Cool! I'll give it a go.

Mark



BM Bala Murugan A.S Syncfusion Team February 22, 2012 03:43 AM UTC

Hi Mark,

Thanks for the update.

We will wait for your response.

Regards,
Bala Murugan A.S



MT Mark Treveil February 29, 2012 09:50 AM UTC

Yep, works a treat.
Thanks
Mark



BM Bala Murugan A.S Syncfusion Team March 1, 2012 05:21 PM UTC

Hi Mark,

Thanks for the update.

Please let us know if you need futher assistance.

Regards,
Bala Murugan A.S


Loader.
Up arrow icon