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

Grid with Partial views

3 Answers 129 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Man
Top achievements
Rank 1
Man asked on 23 Oct 2015, 11:12 AM

Hi,

  I have a scenario where we have a class as follows

Class RiskRegister

{

     int projNo;

     string projName;

     List<Risk> InternalRisks 

     List<Risk> ExternalRisks

}

 

 

The view is shaped as 

 

@Html.Partial("~/Views/RiskRegister/_riskRegister.cshtml")

@Html.Partial("~/Views/RiskRegister/_risksGrid.cshtml", Model.​InternalRisks)

@Html.Partial("~/Views/RiskRegister/_risksGrid.cshtml", Model.ExternalRisks)​

 

As shown, we are re-using the risksGrid as they are the same except for a flag

How do I get the Read action to populate the correct data on the corresponding grid? Please help

3 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 27 Oct 2015, 08:39 AM

Hello Man,

 

As far as I understand you want to populate the Kendo UI Grid from the passed model object. Since in both cases List<Risk> will be used to populate the Kendo UI Grid I believe you can reuse the partial view. 

 

Please refer to the Grid / Binding to local data demo's source code for a sample that shows how to populate the Kendo UI Grid from the model object. 

 

In this case more than one grid will be shown on same page, so please note that they both should have unique Name defined. 

 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Man
Top achievements
Rank 1
answered on 28 Oct 2015, 07:31 PM

Hi Boyan,

   Many thanks for your help. how would we supply a unique name? Please advise as we cannot define this on the view  that defines the grid as that will beat the purpose of making it as a reusable view

0
Boyan Dimitrov
Telerik team
answered on 30 Oct 2015, 12:14 PM

Hello Man,

 

Since there is a different model passed to the partial view you can use the Model object in order to generate the id value. Please refer to Bind the Kendo UI MVC Grid to a DataTable project that demonstrates how to use some of the fields of the Model object in the Grid configuration code. 

 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Man
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Man
Top achievements
Rank 1
Share this question
or