Client Javascript Issue - getDataKeyValue null

5 posts, 0 answers
  1. Manny Siddiqui
    Manny Siddiqui avatar
    13 posts
    Member since:
    Jan 2010

    Posted 26 Jan 2010 Link to this post


    I have been facing the following problem.

    The grid is declared as follows.




    telerik:RadGrid ID="RadGrid1" EnableViewState="true" runat="server" GridLines="Vertical" AllowFilteringByColumn="false" AutoGenerateColumns="false" AllowPaging="true" AllowCustomPaging="true" AllowSorting="true" ShowStatusBar="true" AllowMultiRowSelection="true" Height="600px">


    Grid columns are defined as follows; Please note the DataKeyNames property.

    MasterTableView BorderStyle="None" BorderWidth="0" AllowCustomSorting="true" DataKeyNames="col1">
     <telerik:GridBoundColumn UniqueName="item_num" DataField="item_num" DataType="System.Int32" SortExpression="item_num"  
    ="item number">






    I have multi row select enabled on the grid. After selecting multiple rows, I run the following Javascript to get the value of the data key for those rows but it returns null for

    var radgrdItems = $find("<%=RadGrid1.ClientID %>");
    var mtv = radgrdItems.get_masterTableView();

    // Get array of GridDataItem
    var selectedRows = mtv.get_selectedItems();

    // Works as expected. Returns the count of selected rows.

    for (var i = 0; i < selectedRows.length; i++) {
       var row = selectedRows[i];
       if (row == null)
         alert("row is null");
       else {
          // Works as expected - Returns the id
          alert("get_id()= " + row.get_id());

          // Does not work! Returns null for the get_dataItem()["item_num"]
          alert("item #=" + row.get_dataItem()["item_num"]);

          // Does not work! Returns null for the row.getDataKeyValue("col1")
          alert("col1 key value=" + row.getDataKeyValue("col1"));

    What am I doing wrong?

    I have already looked @ page and could not find the issue in my code (may be I am missing something?)

    Any help is appreciated.


  2. Daniel
    Daniel avatar
    4934 posts

    Posted 26 Jan 2010 Link to this post

    Hello Manny,

    Your MasterTableView should look like this:

    Please notice the ClientDataKeyNames property. I recommend you examine this help topic for more information.

    Extracting key values client-side

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft R3 2016 release webinar banner
  4. Manny Siddiqui
    Manny Siddiqui avatar
    13 posts
    Member since:
    Jan 2010

    Posted 26 Jan 2010 Link to this post

    Thanks Daniel. That fixed the issue.
  5. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 08 Jul 2015 in reply to Daniel Link to this post

    All the links are broken in the post of Daniel
  6. Daniel
    Daniel avatar
    4934 posts

    Posted 09 Jul 2015 Link to this post

    Hello Erik,

    Please try the following links:
    Client-side Editing

    Let me know if you need more information.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft R3 2016 release webinar banner