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

Grid Popup Editor - Razor ForEach - List is null

1 Answer 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 18 Apr 2016, 06:09 PM

Sample from RegistrationModel

1.public int Status      {get; set;}
2.public string Batteries    {get; set;}   
3.public List<Batteries> BatteriesList     {get; set;}

    

 

Sample from Grid

1..Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("EditRegistration"))

 

Sample from popup editor template

01.<h2>Batteries</h2>
02.@{
03.   if(Model.BatteriesList != null)
04.   {
05.    <ul>
06.        @foreach(var x in Model.BatteriesList)
07.        {
08.        <li>x.Selection</li>
09.        }
10.    </ul>
11.   }
12.}

 

  • Model.BatteriesList is always null when the popup renders on-screen.
  • I know the BatteriesList is filled with data.
  • The other fields in my Editor Template show data.
  • Not sure what I am missing here.

Can you assist?

 

 

 

 

 

 

 

 

 

           

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 20 Apr 2016, 07:45 AM

Hello Jason,

The PopUp editor is initialized only once, when the Grid is created, using default model values. This is the reason for the current behavior - the default value of the List is null. The editor templates itself are bound via MVVM, which is why they display the correct model value when the PopUp is opened for each Grid item.

Regards,
Dimiter Madjarov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Jason
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or