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

KendoGrid inside tab with LoadContentFrom controller method called twice

2 Answers 172 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anamika
Top achievements
Rank 1
Anamika asked on 15 Jun 2017, 06:13 AM

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 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 19 Jun 2017, 06:50 AM

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.
0
Anamika
Top achievements
Rank 1
answered on 19 Jun 2017, 07:44 AM

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

Tags
Grid
Asked by
Anamika
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Anamika
Top achievements
Rank 1
Share this question
or