Handling Id's / Primary Keys in Grid

2 posts, 1 answers
  1. Boas
    Boas avatar
    9 posts
    Member since:
    Sep 2008

    Posted 13 Sep 2012 Link to this post


    I'mcurrently evaluating the Kendo UI

    I load some data from a data service and show the data in the grid.

    I have a custom column definition in which i don't show the primary key.

    But how can I access the primary key in the change event ?
    I can't find something like this in the samples

    Can someone help  ?
    Below my jscript code

     $(document).ready(function () {
            var apiUrl = '@(Url.RouteUrl("DefaultApi", new { httproute = "", controller = "Inbox" }))';
                        transport: { read: apiUrl },
                columns: [
                    { title: "SentDate", field: "SentDate", filterable: true, sortable: true, format: "{0:dd.MM.yy}" },
                    { title: "Subject", field: "Subject", filterable: true, sortable:false}
  2. Answer
    Rosen avatar
    3247 posts

    Posted 13 Sep 2012 Link to this post

    Hello Boas,

    You may use Grid's dataItem method to get reference to the data record associated with selected Grid row. Then you can access the id field's value:

           selectable: true,
           change: function() {
                var dataItem = this.dataItem(this.select());
                var id = dataItem.productID;

    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top