Grid Popup Editor - Razor ForEach - List is null

2 posts, 0 answers
  1. Jason
    Jason avatar
    2 posts
    Member since:
    Dec 2015

    Posted 18 Apr Link to this post

    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

    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.   }


    • 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?











  2. Dimiter Madjarov
    Dimiter Madjarov avatar
    2122 posts

    Posted 20 Apr Link to this post

    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.

    Dimiter Madjarov
    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
  3. UI for ASP.NET AJAX banner
Back to Top