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

getDataKeyValue returning null

2 Answers 295 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brad
Top achievements
Rank 2
Brad asked on 25 Jun 2009, 06:08 PM
I have a RadGrid where the first column is declaratively created as GridBoundColumn:
                <%--ID COLUMN--%>
                <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" HeaderText="ID" ReadOnly="True"
                    SortExpression="ID" UniqueName="ID">
                    <ItemStyle Width="35px"></ItemStyle>
                </telerik:GridBoundColumn>

It is defined as the only DataKeyName in the grid:
        <MasterTableView DataKeyNames="ID" DataSourceID="WORDC" PageSize="40" AllowMultiColumnSorting="true"
            EnableHeaderContextMenu="true" >

Defined in ClientSettings I have:
            <ClientEvents OnRowSelected="RowSelected" />

The function RowSelected is defined (to test, there is a bigger "Real" function if I ever get this to work) as:
        function RowSelected(sender, args) {
            var ID = args.getDataKeyValue("ID")
            var label = 
            "ID:" + args.getDataKeyValue("ID");
        } 

With the grid populated, EVERY ID column has a value. But when I select a row and break in the function all I ever get is null for args.getDataKeyValue("ID").

WHAT am I missing??????

Thanks,

Joe B

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 25 Jun 2009, 07:23 PM
Hello Joe,

You should expose your datakeys through the ClientDataKeyNames property.
<MasterTableView DataKeyNames="ID" DataSourceID="WORDC" PageSize="40" AllowMultiColumnSorting="true" ClientDataKeyNames="ID" EnableHeaderContextMenu="true" > 

For more information, please examine the following link:
Extracting key values client-side

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
Brad
Top achievements
Rank 2
answered on 25 Jun 2009, 08:15 PM
Daniel,

THAT did it! 

Thanks,

Joe B
Tags
Grid
Asked by
Brad
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Brad
Top achievements
Rank 2
Share this question
or