1

I have a heirarchical grid defined with a ClientDetailTemplate as follows.

@(Html.Kendo().Grid(Model.NotesList) //Bind the grid to NotesList
      .Name("activityNotesGrid")
      .Columns(columns =>
      {

          // Create a column bound to the Date property
          columns
              .Bound(n => n.Date)
              .Title("DATE")
              .Format("{0:MM/dd/yyyy}");
          // Create a column bound to the Author property
          columns
              .Bound(n => n.Author)
              .Title("ADDED BY");

       })
      .Filterable()
      .Sortable() 
      .Scrollable()
      .DataSource(dataSource => dataSource
        .Ajax()
        .ServerOperation(true)
      )
      .Events(events => events.DataBound("grid_dataBound"))
      .ClientDetailTemplateId("threadedNotesTemplate")
)


<script id="threadedNotesTemplate" type="text/kendo-tmpl" class=".k-grid-header">

        @(Html.Kendo().Grid<ActivityThreadedNoteModel>()
                .Name("grid_#=NoteId#")
                //.Animation(animation => animation.Open(open => open.Fade(FadeDirection.In)))                   
                .Columns(columns =>
                {
                    //columns
                    //    .Bound(p => p.RegistryId)
                    //    .Title("RegistryId");
                    //columns
                    //    .Bound(p => p.RegistryDisplayName)
                    //    .Title("Registry");
                    columns
                       .Bound(p => p.Date)
                       .Format("{0:MM/dd/yyyy}");
                    //.Title("Care Guideline");
                    columns
                       .Bound(p => p.Author);
                    columns                            
                        .Bound(p => p.NoteType);                       
                        //.Title("Process Status");

                       //.Title("Outcome Status");

                    columns
                        .Bound(p => p.Note);
                    columns
                         .Bound(p => p.NoteDetailsId)
                        .ClientTemplate(
                        "# if (ShowInOverview == true) { #" +
                            "<i><a href='" + Url.Action(Constants.Actions.Show_HideInOverview_Note, Constants.Controllers.PatientActivity) + "?**NoteDetailsId**= #=item.NoteDetailsId #&showInOverview=false'" + ">" + Medventive.Registry.UI.Web.Resources.RegistryMVCWeb.HideInOverview + "</a></i>" +
                        "# } else { #" +
                            "<i><a href='" + Url.Action(Constants.Actions.Show_HideInOverview_Note, Constants.Controllers.PatientActivity) + "?NoteDetailsId= #=item.NoteDetailsId #&showInOverview=true'" + ">" + Medventive.Registry.UI.Web.Resources.RegistryMVCWeb.HideInOverview + "</a></i>" +
                        "# } #"
                        );

                })
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .PageSize(10)
                    .Read(read => read.Action(Constants.Actions.LoadPatientThreadedNotes, Constants.Controllers.PatientActivity, new { NoteId = "#=NoteId#" }))
                    )      
                .Pageable()
                .Sortable()
                .ToClientTemplate()
        ) 

    </script>

At run time I get a javascript error that item.NoteDetailsId is undefined. I need to pass the Id to the action/controller. My view model does have the NoteDetailsId property in there and it does have a value in the model.

I am new to kendo, and would appeciate any help here.

1 Answer 1

0

Interestingly with the kendo hierarchical grid, it tries to render the grid before getting the values from the server on an ajax call.

I solved the above issue by passing the id values to the child grid on an ajax call, hiding them while rendering them and using a kendo grid custom command and jquery to call the controller when a corresponding link is clicked for a child item.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.