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

Get DataKeyNames on Client Side

1 Answer 460 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yash
Top achievements
Rank 1
Yash asked on 14 Mar 2012, 05:11 PM
This is the scenario:
I have a RadGrid, in which each row will have a
"GenName(String), Status(RadComboBox), Type(RadComboBox)"
The ClientDataKeyNames are "ID, GenName"

I am doing a CLIENT SIDE BINDING USING A WCF SERVICE for the RadGrid.

Once the data is bound to the radgrid, I will have to click on the "Type" RadComboBox. It has to use Load on Demand. But the data that will be shown in the RadComboBox depends on the ID (ClientDataKeyName) of that particular row. How do I access it??

presently I am using "onclientitemsrequesting" event and below is the even handler,

function GetGenerationVersions(sender, eventArgs) {
                 
                var filterString = eventArgs.get_text();
 
                var rcbElement = sender.get_element();
                // var parentRowID = $(rcbElement).parents("tr").first().prev("tr.rgRow, tr.rgAltRow")[0].id;
                var genID = sender.get_element().parentNode.parentNode.getDataKeyValue("ID");
 
                //.get_parent().get_parent().get_masterTableView().get_dataItems()[0].getDataKeyValue("GenerationID");
                alert(genID.toString());
                var context = eventArgs.get_context();
                context["FilterString"] = filterString;
 
                context["SiteID"] = document.getElementById("<%=lblSiteID.ClientID %>").innerText;
                context["ProductID"] = $find('<%=rcbProducts.ClientID %>').get_selectedItem().get_value();
                context["GenerationName"] = genID;
 
            }

It throws me an Error :  Object doesn't support property or method 'getDataKeyValue'

Please let me know how to deal with it.
Thanks.

Yash

"

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 19 Mar 2012, 03:21 PM
Hi Yash,

getDataKeyValue is method that is supported by the GridDataItem client object. So first you need to get the dataitem for the current row and then to call this method.
Check this help topic for some examples:
http://www.telerik.com/help/aspnet-ajax/grid-extract-key-values-client-side.html
You could loop thought all DataItems of the MasterTableView of the grid until you match the element that is clicked to element of given DataItem.

All the best,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Yash
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or