I'm sure this is a no brainer, but I can't find out how to get the ID of the row selected in javascript.
My RadGrid has the following property.
<
MasterTableView
AutoGenerateColumns
=
"False"
DataKeyNames
=
"loc_Location_ID"
DataSourceID
=
"SqlDataSource1"
>
On clicking a row the client side RowClick method is called. In there I need to get the loc_Location_ID for the selected row. The loc_Location_ID is not displayed in the grid.
How do I get this value after clicking a row?
5 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 16 Jun 2011, 04:57 AM
Hello Brad,
Try the following code snippet in OnRowSelecting event to get the value of DataKeyNames on row click. Hope this helps.
Javascript:
Thanks,
Princy.
Try the following code snippet in OnRowSelecting event to get the value of DataKeyNames on row click. Hope this helps.
Javascript:
<script type=
"text/javascript"
>
function
OnRowSelecting(sender, args)
{
var
key=args.getDataKeyValue(
"loc_Location_ID
"
);
alert(key);
}
</script>
Thanks,
Princy.
0
Brad
Top achievements
Rank 1
answered on 16 Jun 2011, 05:45 AM
I'm using RowClick as set up in the grid like this.
That top of that function now looks like this..
Alas when it runs the alert displays 'locID > null'
I changed my ClientEvents to look like this.
But that made not difference.
The loc_Location_ID is setup in the grid like this.
I'm not sure what else there is.
<ClientEvents OnRowClick="LocationRowClick" />
That top of that function now looks like this..
function LocationRowClick(sender, eventArgs) {
var locID = eventArgs.getDataKeyValue("loc_Location_ID");
alert(' locID > ' + locID);
Alas when it runs the alert displays 'locID > null'
I changed my ClientEvents to look like this.
<
ClientEvents
OnRowSelected
=
"LocationRowClick"
/>
But that made not difference.
The loc_Location_ID is setup in the grid like this.
<
MasterTableView
AutoGenerateColumns
=
"False"
DataKeyNames
=
"loc_Location_ID"
DataSourceID
=
"SqlDataSource1"
>
I'm not sure what else there is.
0
Accepted
Princy
Top achievements
Rank 2
answered on 16 Jun 2011, 07:42 AM
Hello Brad,
In order to get DataKeyValues from client side, try setting the ClientDataKeyNames as shown below.
aspx:
Thanks,
Princy.
In order to get DataKeyValues from client side, try setting the ClientDataKeyNames as shown below.
aspx:
<
MasterTableView
DataKeyNames
=
"loc_Location_ID"
ClientDataKeyNames
=
"loc_Location_ID"
>
</
MasterTableView
>
Thanks,
Princy.
0
Brad
Top achievements
Rank 1
answered on 16 Jun 2011, 07:46 AM
Give that man a cigar (or a beer)
That did the trick Princy. Thanks so much
That did the trick Princy. Thanks so much
0
Ahmad
Top achievements
Rank 1
answered on 16 May 2020, 12:05 PM
Hai,
How to dynamically bind pivot columns from datatable (Pivot Columns changes based on date) in RadGrid. Can You Please suggest
any solution? (alihashimc93@gmail.com). Here I attach the format of output
Thanks & Regards