Grid Details Template Guid Id Problems

5 posts, 0 answers
  1. Chris
    Chris avatar
    5 posts
    Member since:
    Sep 2014

    Posted 31 Oct 2014 Link to this post


    We have multiple Heirachical grids but are having issues when trying to construct routing data that contains Guids. The following Template works fine, the Controller receives the Guid Value (Query String Parameters "ruleId:22222222-2222-2222-2222-222222222222") .The content of the tab being a partial view containing a sub-grid:

    <script id="RuleDetailTemplate" type="text/x-kendo-template">
        @(Html.Kendo().TabStrip()
            .Name("detailTabs_#=RuleId#")
            .Items(items =>
            {
                items.Add().Text(Resources.DetailsLabel)
                    .Selected(true)
                    .LoadContentFrom("RuleDetailsTab", "Administration",
                        new { ruleId = "#=RuleId#" });
    ...
            }).ToClientTemplate()
        )
    </script>

    However if we replace the TabStrip with a Splitter the controller receives (Query String Parameters "ruleId:#=RuleId#"):

    <script id="RuleDetailTemplate" type="text/x-kendo-template">
            @(Html.Kendo().Splitter()
            .Name("detailsContainer_#=RuleId#")
            .Panes(panes =>
            {
                panes.Add()
                   .LoadContentFrom("RuleDetailsTab", "Administration",
                        new { ruleId = "#=RuleId#" });

            }).ToClientTemplate()
        )
    </script>

    We do not specifically want to use a Splitter in this case as there is only one panel but can not embed the sub grid directly as it will also not allow us to build the Model properties for a create.


  2. Chris
    Chris avatar
    5 posts
    Member since:
    Sep 2014

    Posted 31 Oct 2014 in reply to Chris Link to this post

    Sorry it couldn't post multiple sections in to the same window. When trying to embed the grid directly into a template rather than in a partial view via an ajax call-back I get the following issues

    1. Type conversion it thinks the template reference is a string and does not expand it to the Guid (note this is a more complex example). 

    <script id="SubscriberDetailTemplate" type="text/x-kendo-template">
        @(Html.Kendo().Grid<SubscriptionViewModel>()
            .Name("subscriptionGrid_#=SubscriberId#") // This works OK the grid gets a unique name
     ...   
             .DataSource(dataSource => dataSource.Ajax()
                .Model(model =>
                {
                    model.Id(sub => sub.SubscriptionId);
                    model.Field(sub => sub.SubscriptionId).DefaultValue(Guid.Empty);
                    model.Field(sub => sub.Subscriber).DefaultValue(new SubscriberReference() { Name = "#=Name#", Value = "#=SubscriberId#" }); // This does not work
    ...
                })
                .Create(create => create.Action("Create", "Subscription"))
                .Read(read => read.Action("ReadSubscriptions", "Subscription",
                     new { subscriberId = "#=SubscriberId#" })) // This works OK the Guid is received as a Guid
    ...
            )
            .ToClientTemplate()
        )
    </script>

    2. None of the sub-grid cell content EditorTemplate Events get fired (they do when the sub-grid is in a partial view).

    Most columns contain dynamic enumerables (Name,Value pairs). In many cases they need filtering based on other items in the row model OR when selected they need to update related columns. This is all done using Editor Templates for these View Model fields containing DropDownLists and using their Selected/Change event to find and update the other columns. Setting break points in Chrome, the events are fired when the Editor template is part of a Grid in a Partial View, they are not fired when is is part of a Grid directly in a Client Details Template.






























  3. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 04 Nov 2014 Link to this post

    Hello Chris,

    To the questions:

    1) The default value object is executed on the server side (before the items are actually send to the client) and this #= # expression won't be evaluated. If you want to change the default values you will need to manually update the DataSource configuration when the Grid is initialized. 

    As a work-around you can dynamically update the model , when the edit or save events are triggered and retrieve that value from the master Grid. e.g.

    function save(e) {
      var parentGrid = $("#parentGridName").data("kendoGrid");                       
      var parentRow = e.container.closest(".k-detail-row").prev(".k-master-row");                       
      var parentDataItem = parentGrid.dataItem(parentRow);
     
      e.model.set("CodeTypeId", parentDataItem.Id);
    }

    2) Please demonstrate your case with a small demo so we can investigate why those events inside of the widgets inside the editor templates are not runnable.

    Kind Regards,
    Petur Subev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  4. Chris
    Chris avatar
    5 posts
    Member since:
    Sep 2014

    Posted 04 Nov 2014 in reply to Petur Subev Link to this post

    Hello Petur

    Thank you for the response. I have raised this as a support ticket now as I did not want to post large portions of our code on an open forum. 

    I will try the Edit Event work around to set the sub-grid model reference values from the parent rows values. The ticket I raised gives more description: it would be preferable to load the sub-grid as a partial view then it can share all the same code etc. used when it is placed in a TabStrip.

    As for point 2 the Views/Templates/Models in question are all attached to the ticket which describes a specific example.

    Regards

    Chris
  5. Kelly
    Kelly avatar
    1 posts
    Member since:
    May 2014

    Posted 26 Nov 2014 Link to this post

    I am having a similar problem. Was this ever resovled?
Back to Top