Hi,
How can I get the selected cell value from this event in JS? Seems like this should be documented in the manual, but I am not seeing it.
I tried this (after looking at other threads):
But i get "Microsoft JScript runtime error: 'undefined' is null or not an object" for the get_cell().
Thanks
How can I get the selected cell value from this event in JS? Seems like this should be documented in the manual, but I am not seeing it.
I tried this (after looking at other threads):
function Test_OnCellSelected(sender, args) {
var gridDataItem = args.get_gridDataItem();
var cell = gridDataItem.get_cell();
}
But i get "Microsoft JScript runtime error: 'undefined' is null or not an object" for the get_cell().
Thanks
6 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 01 Aug 2013, 03:24 AM
Hi Kernelk,
Please try the below code snippet to access the cell selected values.
ASPX:
JS:
Hope this helps.
Thanks,
Princy
Please try the below code snippet to access the cell selected values.
ASPX:
<
ClientSettings
Selecting-CellSelectionMode
=
"MultiCell"
>
<
ClientEvents
OnCellSelected
=
"OnCellSelected"
/>
</
ClientSettings
>
JS:
<script type=
"text/javascript"
>
function
OnCellSelected(sender, eventArgs) {
var
columnName = eventArgs.get_column().get_uniqueName();
var
data = eventArgs.get_gridDataItem().get_cell(columnName);
alert(data.innerHTML);
//Get the cell value
}
</script>
Hope this helps.
Thanks,
Princy
0

kernelk
Top achievements
Rank 1
answered on 01 Aug 2013, 05:37 PM
Thanks Princy!
I have another follow-up question:
Is it possible from the JS OnSelectedCell to get the actual index of the row that would correspond to the index from the csharp side of RadGrid.MasterTableView.Items[selectedRowIndex] ?
We are using grid paging and args.get_row().rowIndex appears to be relative to the grid page.
Thanks again.
I have another follow-up question:
Is it possible from the JS OnSelectedCell to get the actual index of the row that would correspond to the index from the csharp side of RadGrid.MasterTableView.Items[selectedRowIndex] ?
We are using grid paging and args.get_row().rowIndex appears to be relative to the grid page.
Thanks again.
0

Princy
Top achievements
Rank 2
answered on 02 Aug 2013, 04:24 AM
Hi Kernelk,
I'm not clear about your requirement,I guess you want to get the selected cell row index on the CellSelected event.Please try the below code snippet.If this doesn't help,please elaborate on your requirements.
JS:
Thanks,
Princy
I'm not clear about your requirement,I guess you want to get the selected cell row index on the CellSelected event.Please try the below code snippet.If this doesn't help,please elaborate on your requirements.
JS:
<script type=
"text/javascript"
>
function
OnCellSelected(sender, eventArgs) {
var
rows = eventArgs.get_gridDataItem();
var
columnName = eventArgs.get_column().get_uniqueName();
var
data = rows.get_cell(columnName);
alert(data.innerHTML);
var
rowIndex = rows.get_itemIndexHierarchical();
//get the Row Index
alert(rowIndex);
}
</script>
Thanks,
Princy
0

kernelk
Top achievements
Rank 1
answered on 02 Aug 2013, 05:56 PM
Hi Princy,
To clarify, i want the index of the item as i would find it from RadGrid.MasterTableView.Items[selectedRowIndex] on the c# side. I am aware of the method you provided, but the index returned appears to be relative to the "grid page" (we are using paging of the grid).
So, if i am on grid page 10, the first row index returns 0 instead of the index of the item relative to the entire list of items.
Thanks,
To clarify, i want the index of the item as i would find it from RadGrid.MasterTableView.Items[selectedRowIndex] on the c# side. I am aware of the method you provided, but the index returned appears to be relative to the "grid page" (we are using paging of the grid).
So, if i am on grid page 10, the first row index returns 0 instead of the index of the item relative to the entire list of items.
Thanks,
0

Princy
Top achievements
Rank 2
answered on 09 Aug 2013, 05:16 AM
Hi Kernelk,
The default behavior of the row index is based on the paging,in each page the index starts from 0.If you want to identify the row being selected,the best method is to use DataKeyNames.Please try the below code snippet.
ASPX:
JS:
Thanks,
Princy
The default behavior of the row index is based on the paging,in each page the index starts from 0.If you want to identify the row being selected,the best method is to use DataKeyNames.Please try the below code snippet.
ASPX:
<
MasterTableView
DataKeyNames
=
"OrderID"
ClientDataKeyNames
=
"OrderID"
>
JS:
<script type=
"text/javascript"
>
function
OnCellSelected(sender, eventArgs) {
var
data;
var
rows = eventArgs.get_gridDataItem();
var
columnName = eventArgs.get_column().get_uniqueName();
data = rows.get_cell(columnName);
alert(data.innerHTML);
//Selected cell value
var
rowIndex = rows.getDataKeyValue(
"OrderID"
);
//Selected rows DataKeyValue
alert(rowIndex);
}
</script>
Thanks,
Princy
0

kernelk
Top achievements
Rank 1
answered on 09 Aug 2013, 04:32 PM
Thanks Princy,
I will give this a shot.
I will give this a shot.