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

Dynamic grid in Partial view - Multiple grid on single page

1 Answer 846 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sadaf
Top achievements
Rank 1
Sadaf asked on 08 Jan 2020, 06:30 PM

Hi I have need to display multiple dynamic grid on single page. I created partial view with dynamic grid binding and passing model and method name to bind data from view. First grid displays data and call data read action but rest of the grid do not display data or call method. It shows column names but no data. 

This is partial view

@(Html.Kendo().Grid<dynamic>()
        .Name(@ViewData["Name"].ToString())
        .Columns(columns =>
    {
        foreach (System.Data.DataColumn column in Model.Columns)
        {
            columns.Bound(column.ColumnName);
        }
    })
        .Pageable()
        .Sortable()
        .Filterable()
        .Groupable()
        .Scrollable()
        .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(50)
        .Model(model =>
            {
                 foreach (System.Data.DataColumn column in Model.Columns)
                    {
                        var field = model.Field(column.ColumnName, column.DataType);
 
                    }
            })
        .Read(read => read.Action(@ViewData["ActionName"].ToString(), "RunData"))
    )
    )

 

 

In main view I am passing list of datatable and in partial view it is getting datatable from ajax call. I have created 3 separate method (ReadData1, ReadData2, ReadData3) in RanData controller.
Thanks in advance.

 

@model List<System.Data.DataTable>
 
 
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
 
 
    <div>
        @{Html.RenderPartial("dGrid", Model[0], new ViewDataDictionary { { "ActionName", "ReadData1" },  { "Name", "Grid1" } });}
    </div>
 
   <div>
        @{Html.RenderPartial("dGrid", Model[1], new ViewDataDictionary { { "ActionName", "ReadData2" } ,  { "Name", "Grid2" } });}
    </div>
 
   <div>
       @{Html.RenderPartial("dGrid", Model[2], new ViewDataDictionary { { "ActionName", "ReadData3" }, { "Name", "Grid3" } });}
 
   </div>

1 Answer, 1 is accepted

Sort by
0
Sadaf
Top achievements
Rank 1
answered on 09 Jan 2020, 10:30 AM
never mind I am able to make it working. Issue was data was having field name with special character "[" or ' . 
Tags
Grid
Asked by
Sadaf
Top achievements
Rank 1
Answers by
Sadaf
Top achievements
Rank 1
Share this question
or