this.dataItem($(e.currentTarget).closest("tr")); on custom command does not work when passing in model

2 posts, 1 answers
  1. Liza
    Liza avatar
    3 posts
    Member since:
    Oct 2012

    Posted 29 Oct 2012 Link to this post

    I am using custom commands and trying to get the selected dataitem. I am getting an error inside 
    the javascript call on this.dataitem
    By debugging in chrome i can see that the is not populated on binding directly to a model. 
    Where as in the telerik examples it is populated.
    This is my code:
    @using Kendo.Mvc.UI
         var addressList = Model.DataList as List<Intelli.Data.Parties.EFDAL.Entity.GeoAddress>;
    <script type="text/javascript">
      function viewgeoaddress(e) {
             //prevent the request which will be made by default
            //error occurs here!!
             var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
        .Columns(columns =>
                    columns.Bound(p => p.ID).Title("ID").Hidden(true);
                    columns.Bound(p => p.Address).Title("Address").Width(160);
                    columns.Bound(p => p.Region).Title("Region").Width(80);
                    columns.Bound(p => p.Zipcode).Title("Zipcode").Width(80);
                    columns.Command(commands => commands
                                                    .HtmlAttributes(new { style = "text-align: center" }));
                    columns.Command(commands => commands
                                                    .HtmlAttributes(new { style = "text-align: center" }));               
        .Scrollable(scr => scr.Enabled(true).Height(300))
        .Sortable(builder => builder.Enabled(true))
        .Resizable(resizing => resizing.Columns(true))
        //                .DataSource(dataSource => dataSource
        //                                              .Ajax()
        //                                               .ServerOperation(false)
        //                    )
  2. Answer
    Vladimir Iliev
    Vladimir Iliev avatar
    2196 posts

    Posted 01 Nov 2012 Link to this post

    Hi Liza,

    From the provided information it seems that the Grid currently use ServerBinding, in which the data on the client side is rendered directly into the Grid rows. You should enable Ajax binding to use the dataItem method or find the needed cell and get it's data using jQuery Html method

    Kind Regards,
    Vladimir Iliev
    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