KendoGrid inside tab with LoadContentFrom controller method called twice

3 posts, 0 answers
  1. Anamika
    Anamika avatar
    157 posts
    Member since:
    Mar 2014

    Posted 15 Jun 2017 Link to this post

    Hello,

     

    I have a tab stripe and the tab Content which is a grid bound to datatable gets loaded with Ajax call like this

          @(Html.Kendo().TabStrip()
    .Name("myKendoTabs")
    .Animation(animation =>
    {
        animation.Enable(false);
    })
    .SelectedIndex(0)
        .Items(t =>
        {
            t.Add().Text("Objektliste").LoadContentFrom("GetObjectsforAdress", "AdressActivity", new { strAdressID = ViewBag.SelAdressID });
        })
            )

     

    And the GetObjectsforAdress method in Controller Returns a partial view

    return PartialView("DocumentList", ds.Tables[0]);

     

    and the partialview is like this

                @(Html.Kendo().Grid(Model)
        .Name("Grid_ObjActivity")
                      .Scrollable()
         .HtmlAttributes(new { style = "height: 300px;" })
         .DataSource(dataSource1 => dataSource1
                        .Ajax()
                        .PageSize(100)
                        .Model(model1 =>
                        {
                            if (Model != null)
                            {
                                foreach (System.Data.DataColumn ocolumn in Model.Columns)
                                {
                                    model.Field(ocolumn.ColumnName, ocolumn.DataType);
                                }
                            }
                        })
     .ServerOperation(false)
                         )
                          .Resizable(resize => resize.Columns(true))
        .Columns(columns =>
        {
            if (ViewBag.ObjListHeader != null)
            {
                for (int j = 0; j < ViewBag.ObjListHeader.GetLength(0); j++)
                {
                  
                                columns.Bound(ViewBag.ObjListHeader[j, 0]).Title(ViewBag.ObjListHeader[j, 0]).Width(120);
                       
                }
            }
        })
        .Selectable(selectable => selectable
                .Mode(GridSelectionMode.Single))
    .Filterable(filterable => filterable
                                      .Extra(false)
                                      .Operators(operators => operators
                                          .ForString(str => str.Clear()
                                              .StartsWith("Starts with")
                                              .IsEqualTo("Is equal to")
                                              .IsNotEqualTo("Is not equal to")
                                          ))
                                      )
                                  .Groupable()
                                  .Reorderable(r => r.Columns(true))
                        .Resizable(r => r.Columns(true))
                                  )

     

    The Problem is when the tab is selected then GetObjectsforAdress method is called twice. Loads once and again loads. Not sure why it is called twice.

    Can you please suggest what am i doing wrong here.

     

    Thanks

     

    Anamika

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 19 Jun 2017 Link to this post

    Hello,

    I am afraid that I was not able to replicate such behavior. Please refer to the attached project and let us know if you face the same problem? 

    Regards,
    Boyan Dimitrov
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Anamika
    Anamika avatar
    157 posts
    Member since:
    Mar 2014

    Posted 19 Jun 2017 in reply to Boyan Dimitrov Link to this post

    Looks like i had

    $("#myKendoTabs").kendoTabStrip(); in

    document.ready function. And that could be the culprit reinitializing Kendo tab. I remember adding this line as in one tab  have a Kendo Editor and that was read only if i do not call this in document ready.

     

    Thnaks anyways

     

    Anamika

Back to Top