This is a migrated thread and some comments may be shown as answers.

How to retrieve primary key

4 Answers 129 Views
Grid
This is a migrated thread and some comments may be shown as answers.
shane
Top achievements
Rank 1
shane asked on 10 Jul 2009, 06:53 AM
How to retrieve primary key field values for selected items, when the primary key field column visible set to "false"

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 10 Jul 2009, 07:26 AM
Hello Shane,

For your convenience I created a sample that demonstrates how to attain this.

I hope this helps.

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
shane
Top achievements
Rank 1
answered on 13 Jul 2009, 03:05 AM
How to achieve this in client side
0
shane
Top achievements
Rank 1
answered on 13 Jul 2009, 03:16 AM
Actually,I want to set the KeyColumn visible to false,but I find I cant retrieve its value in client side by cell.innerHtml,so I try to change the column width to 0px,but the Column still in grid.How can I do???
0
Shinu
Top achievements
Rank 2
answered on 13 Jul 2009, 04:32 AM
Hi Shane,

Try setting the ClientDataKeyNames to the primary DataField. When you add the value of the DateField to the ClientDataKeyNames array, RadGrid makes that column's value available through the getDataKeyValue() function of the GridDataItem client-side object.

.aspx
 
  . . . 
<telerik:GridBoundColumn DataField="CustomerID" Visible="False" HeaderText="CustomerID" SortExpression="CustomerID" UniqueName="CustomerID"
</telerik:GridBoundColumn> 
  . . . 

.javascript
 
<script type="text/javascript"
 function RowSelected(sender, args) //Client side Rowselected event of radgrid
 { 
     alert(args.getDataKeyValue("CompanyName")); 
 } 
</script> 

Checkout the link to know more about Extracting key values client-side

-Shinu.
Tags
Grid
Asked by
shane
Top achievements
Rank 1
Answers by
Daniel
Telerik team
shane
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or