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

Sub Grid in pop-up editor window

2 Answers 413 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AP
Top achievements
Rank 1
Iron
Iron
Veteran
AP asked on 14 May 2013, 10:30 AM
I've got a complex form, which requires a pop-up edit window. There are several hierarchical tables that also require editing. I hoped to do this with sub-grids, embedded in the editor template of the main grid.

However, I have encountered two issues.
  • Passing the main ID to the read action of the sub grid - using the Model.ID doesn't work - it is just zero.
@(Html.Kendo().Grid<CDIFFAudit.Models.AntibioticHistory>()
 .Name("ahGrid")
 .Events(e=>e.Edit("onEditah"))
 .Columns(columns =>
     {
         columns.Bound(p => p.ID).Title("ID");
         columns.Bound(p => p.AntibioticID).Title("ID");
         columns.Bound(p => p.StartDate).Title("Start").Format("{0:d}"); ;
         columns.Bound(p => p.Appropriate).Title("Appropriate?");
         columns.Command(command => { command.Edit(); });
     })
      .ToolBar(commands=>commands.Create())
.Editable(editable=>editable
     .Mode(GridEditMode.PopUp))
     .DataSource(datasource => datasource
         .Ajax()
         .Model(m=>m.Id(p=>p.ID))
         .PageSize(10)
         .Read(read => read.Action("GetAntibioticHistory", "CDIff", new { CDiffID =  Model.ID }))
         .Create(create=>create.Action("insertAntibioticHistory","CDIff"))
         .Update(update=>update.Action("updateAntibioticHistory","CDiff"))
         
         )
 
         .Pageable()
         .Sortable()
         .Filterable()
         )

 

The only answer I can fin about this is this post (http://stackoverflow.com/questions/13384901/grid-into-grid-popup-editor-passing-id-parameter-in-sub-grid ) on StackOverflow , which seems like a complete bodge, and one I don't want, as I'll have at least four grids on this edit form (if it can be made to work).

  • Editing the sub-grids data in a pop-up form doesn't work.  When I hard-coded a real ID into the read method, the grid displayed data, but the pop-up form just displayed a 0  (screen shot attached).

I need to know whether kendo can support a complex editing scenario such as this, otherwise I'll have to take another route to achieve what's needed.



2 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 16 May 2013, 07:34 AM
Hello Andrew,

  1. Passing the main ID inside of the editor template with the HTML helpers is not possible. Inside of the editor template only bindings are available:
    Mainly value and text bindings.
    http://docs.kendoui.com/getting-started/framework/mvvm/bindings/value

    To edit a hierarchy we suggest to create hierarchy like shown here: http://demos.kendoui.com/web/grid/hierarchy.html

  2. To make the Grids inside of the popup editor you will need to either use JavaScript initialization like shown here (the html demo) - you can see that you have the container and the model to successfully initialize the Grid and pass the additional masterID to the server:
    http://demos.kendoui.com/web/grid/editing-custom.html 

    Another approach would to keep your current setup, set the AutoBind option of the Grid to false and manually call the dataSource.read({masterid:e.model.masterID}) methods of the Grids inside of the edit event of the Grid. This way you have the masterID available inside of the edit event.



Kind regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
AP
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 16 May 2013, 07:45 AM
Petur, 

Thanks for your response, but it's disappointing news.  It simply doesn't make sense to present the data in a hierarchical grid (it's essentially a questionnaire with repeating sections),   I also have to dynamically alter the form to display items based on previous answers.

I'll have to re-think my approach to this now.
Tags
Grid
Asked by
AP
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Petur Subev
Telerik team
AP
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or