Signalr + Grid Detail Auto Collapsing

2 posts, 0 answers
  1. Paito
    Paito avatar
    1 posts
    Member since:
    Mar 2017

    Posted 12 Apr Link to this post

    Hi,

    I am currently using a Grid with a SignalR datasource and expandable rows to show a Detail Template, every time a new record is created in the grid from the server (onPush) it collapses any/all detail templates which you may have been viewing. Kinda annoying, any way to resolve this?

    @(Html.Kendo().Grid<Models.MyView>()
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(p => p.Column1);
            columns.Bound(p => p.Column2);
        })
        .ClientDetailTemplateId("template")
        .Sortable()
        .Scrollable(s => s.Height("auto"))
        .Filterable()
        .Pageable()
        .Navigatable()
        .DataSource(dataSource => dataSource
            .SignalR()
            .AutoSync(true)
            .ServerFiltering(true)
            .ServerPaging(true)
            .ServerSorting(true)
            .ServerAggregates(true)
            .ServerGrouping(true)
            .PageSize(20)
            .Events(events => events.Push("onPush"))
            .Sort(s => s.Add("Posted").Descending())
            .Transport(tr => tr
                .Promise("hubStart")
                .Hub("hub")
                .Client(c => c
                    .Read("read")
                    .Create("create")
                    .Update("update")
                    .Destroy("destroy")
                )
                .Server(s => s
                    .Read("read")
                    .Create("create")
                    .Update("update")
                    .Destroy("destroy")
                )
            )
            .Schema(schema => schema
                .Data("Data")
                .Total("Total")
                .Aggregates("Aggregates")
                .Groups("Groups")
                .Model(model =>
                {
                    model.Id("ID");
                    model.Field("Column1", typeof(string));
                    model.Field("Column2", typeof(string));
                })
            )
        )
    )

    <script id="template" type="text/kendo-tmpl">
       @(Html.Kendo().TabStrip()
                .Name("tabStrip_#=ID#")
                .SelectedIndex(0)
                .Animation(animation => animation.Open(open => open.Fade(FadeDirection.In)))
                .Items(items =>
                {
                    items.Add().Text("Detail")
                        .LoadContentFrom("Detail", "Home", new { ID= "#=ID#" })
                        .Selected(true);
                })
                .ToClientTemplate())
    </script>

     

    Thanks!

  2. Stefan
    Admin
    Stefan avatar
    918 posts

    Posted 17 Apr Link to this post

    Hello Paito,

    This can be achieved only with a custom logic to persist the expanded rows, and then to manually expanded them once the new data is set.

    I can suggest checking the following example demonstrating this. The example is using a button to simulate refresh, but a similar logic can be used when a new data is set and the Grid is rebound:

    http://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/state/persist-expanded-rows

    Regards,
    Stefan
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top