Problem adding Grid to Editor Template

4 posts, 1 answers
  1. James
    James avatar
    2 posts
    Member since:
    Feb 2012

    Posted 01 Mar 2013 Link to this post

    Problem 1:
    I can't seem to get a grid in a Editor Template to work in a popup editor window of a grid.  I have attached a sample of this issue.  If you select the Grid Editor Menu Item you will see that it crashes.  If you remove the Html.Partial statement from the TopLevelItem Editor, you will see that it works.  To demostrate that the template works fine, I added a Direct Edit Menu ITem that calls the Template which led me to my second problem....

    Problem 2:
    If you use the Direct Edit menu item at first glance everything looks ok.  If you pay close attention to the dropdown for ItemType (not the one in the grid, that is itemtype2 and works fine), it doesn't select the correct default value.  Upon forther inspection, it doesn't seem to behave in the same manner as when inside the Grid Popup editor.  If you post it back, only the ID is trying to be return (inspect the Request object's Forms collection) but not the entire model.  The Item Type is null.  Again, this works fine inside a Grid Popup.

    My intial thought was to host the editor in my own window using custom actions on the grid, but then I ran into problem 2.

    Any thoughts on this?  Is this a bug?  Unintended use?
  2. Answer
    Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2194 posts

    Posted 05 Mar 2013 Link to this post

    Hi James,

     
    Please note that when grid with PopUp editor template contains another grid which is editable, the second grid should be converted to client template using the ToClientTemplate method. Please check the example below:

    Updated grid code:

    @(Html.Kendo().Grid<MvcApplication1.Models.SecondLevelItem>()
        .Name("SecondLevelItems")
        .Editable()
        .DataSource(d =>
        {
            d.Ajax()
                .Read("GridEditor_SecondLevel_Read", "Home")
                .Update("GridEditor_SecondLevel_Update", "Home")
                .Model(m => m.Id(f => f.ID));
        })
        .Scrollable()
        .Columns(c =>
        {
            c.Bound(i => i.ID).Width(100);
            c.Bound(i => i.Description).Width(100);
            c.Bound(i => i.StartDate).Width(100);
            c.Bound(i => i.EndDate).Width(100);
            c.Bound(i => i.ItemType2).ClientTemplate("#=ItemType2.Description#").Width(100);
            c.Command(i => i.Edit()).Width(100);
        }).ToClientTemplate()
    )

    Also after checking the provided project it seems that is use unsupported version of jQuery (v.1.7.1) - please note that KendoUI v.2012.3.1315 supports jQuery v.1.8.2 and you should upgrade to it. For more information you can check the JavaScript dependencies article.

    Kind Regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. James
    James avatar
    2 posts
    Member since:
    Feb 2012

    Posted 08 Mar 2013 Link to this post

    That solved my first issue.  Any thoughts on the second one?  The drop down does not appear to behave in the same way that it does when inside the grid editor.  The value is not set and only the ID comes back when posted.
  4. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2194 posts

    Posted 12 Mar 2013 Link to this post

    Hi James,

     
    Submitting input values using from element is not directly related to the KendoUI but to a general programming knowledge. Basically on form submit the values of all valid input elements will be submitted to the server and current behavior is expected.

    Kind Regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top