Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9021019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:09:28+00:00 2026-06-16T05:09:28+00:00

As is typical for grids in a dashboard application that monitors dynamically changing data,

  • 0

As is typical for grids in a “dashboard” application that monitors dynamically changing data, my (Telerik) Kendo UI grid is refreshed with fresh data periodically, every 60 seconds:

grid.dataSource.data(freshData);
grid.refresh();  // have been informed this refresh may not be necessary

The schema does not change, but some new rows might show up in the dataset and some might have been removed.

Although the grid.refresh() leaves the groupings intact, and the sort state is also preserved, any collapsed groups get expanded.

QUESTION: How to preserve (or restore) the expanded/collapsed state of the groups (so a user focusing on a particular expanded group with the other groups collapsed is not inconvenienced/frustrated by the periodic updates in which every group gets re-expanded by default)?

EDIT: Some Winforms grids provide a way to “take a snapshot” of the group expand/collapse state before refreshing data, and then to reapply that state after the datasource refresh. If the group header rows in the Kendo UI grid had UIDs (that survived a refresh) it could be done. But see the suggested approach below that does not involve persistent UIDs.

USE CASE:
Here is a typical if somewhat dramatic use case for this feature. Center for Disease Control is monitoring real-time outbreaks of a particular strain of flu, by city. Every 15 seconds the dataset is being refreshed. They happen to be focusing at the moment on Los Angeles and have that city expanded, and the other cities collapsed. If every 15 seconds the entire grid expands, it pisses off the doctors at the CDC and they go in and strangle the programmer and then they go home to play golf, and everyone in Los Angeles succumbs. Does Kendo really want to be responsible for that disaster?

POSSIBLE FEATURE ENHANCEMENT SUGGESTION:
Ignore my suggestion about a UID above. Here’s a better way.
The grid has

<div class="k-group-indicator" data-field="{groupedByDataFieldName}">
    ...
</div>

Now, if that k-group-indicator div could contain a list of the distinct values of data-field with each key’s associated data being the expanded/collapsed state of the corresponding section, it would then be possible to save that list to a buffer before making a call to the dataSource.data( someNewData) method, and then in the eventhandler listening for dataBound event, those expand states could be reapplied. To find the corresponding grouping section for the grouping value, it would be very helpful if the k-grouping-row could have a property called group-data-value which held the grouping value of the particular grouping section, e.g. “Sales” or “Marketing” if one were grouping by a data-field called Department.

<div class="k-group-indicator" data-field="dept" data-title="Dept" data-dir="asc">
       ...
   <div class="k-group-distinct-values">
     <div group-data-value="Sales" aria-expanded="false" />
     <div group-data-value="Events Planning" aria-expanded="true" />
   </div>  
</div>

and then in the k-grouping-row: <tr class="k-grouping-row" group-data-value="Sales">

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:09:29+00:00Added an answer on June 16, 2026 at 5:09 am

    It is understandable that this isn’t a built-in feature. It is pretty complicated because if you have nested groupings, you would have to remember each collapsed group in the hierarchy that it existed in. Since items will be moving in and out of the DataSource, this would be a pain to track.


    That said, here is a very hackish way to accomplish what you want, as long as you don’t get too complicated. It just uses the groupHeaderTemplate property to add a UID to each grouping row. I am just using the column name + value as the UID, which is technically wrong if you get into multiple groupings, but it is good enough for an example.

    From there, before you refresh you can find the collapsed groups from the ARIA attribute that Kendo has now (side-note, you have to be using 2012 Q3 for this to work). Then drill down and get the UID that was added by the template.

    After the refresh, you can find the rows with a matching UID and pass them to the grid’s .collapseGroup() function to re-collapse it.

    Here is a working jsFiddle that demonstrates this.

    And the code from the jsFiddle copy/pasted in (please note that I only set the template on the City column, so only the City column will preserve grouping collapse in this example!):

    HTML:

    <button id="refresh">Refresh</button>
    <div id="grid" style="height: 380px"></div>
    

    JavaScript:

    var _getCollapsedUids = function () {
        var collapsedUids = [];
        $("#grid .k-grouping-row span[data-uid]")
            .each(function(idx, item) {
                if($(item)
                   .closest(".k-grouping-row")
                   .children("td:first")
                   .attr("aria-expanded") === "false") {
                    collapsedUids.push($(item).data("uid"));
                }
            }
        );
        return collapsedUids;
    };
    
    var _collapseUids = function (grid, collapsedUids) {
        $("#grid .k-grouping-row span[data-uid]")
            .each(function(idx, item) {
                if($.inArray($(item).data("uid"), collapsedUids) >= 0) {
                    console.log("collapse: " + $(item).data("uid"))
                    grid.collapseGroup($(item).closest("tr"));
                }
            }
        );
    };
    
    var refresh = function () {
        var collapsedUids = _getCollapsedUids();
        var grid = $("#grid").data().kendoGrid;
        grid.dataSource.data(createRandomData(50));
        _collapseUids(grid, collapsedUids);
    };
    
    $("#refresh").click(refresh);
    
    $("#grid").kendoGrid({
        dataSource: {
            data: createRandomData(50),
            pageSize: 10
        },
        groupable: true,
        sortable: true,
        pageable: {
            refresh: true,
            pageSizes: true
        },
        columns: [ {
                field: "FirstName",
                width: 90,
                title: "First Name"
            } , {
                field: "LastName",
                width: 90,
                title: "Last Name"
            } , {
                width: 100,
                field: "City",
                groupHeaderTemplate: '<span data-uid="City-#=value#">#= value #</span>'
            } , {
                field: "Title"
            } , {
                field: "BirthDate",
                title: "Birth Date",
                template: '#= kendo.toString(BirthDate,"dd MMMM yyyy") #'
            } , {
                width: 50,
                field: "Age"
            }
        ]
    });
    

    Personally I don’t really like this solution at all. It is way too hacky and way too much DOM traversal. However without re-implementing the grid widget I can’t think of a better way to do it. Maybe it will be good enough for what you are trying to accomplish or give you a better idea.


    One last note; I checked the Kendo UI source code and it does not appear to track which groupings are expanded/collapsed. They do something similar to what I did with the aria attribute, but instead check the class that drives the icon state:

                if(element.hasClass('k-i-collapse')) {
                    that.collapseGroup(group);
                } else {
                    that.expandGroup(group);
                }
    

    If you are not using Kendo 2012 Q3 and can’t use the aria-expanded attribute, you could change the code to check the icon class instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data grid bound to a data source in the typical way
I have a form that consists of two data grids and a button. Datagrid
My typical workflow is that I develop on localhost, but with Google Apps Marketplace
I have a typical Pyramid web application setup. The application directory (I don't know
I'm working with an asp.net application that produces large PDF documents from HTML. The
Using the typical definition of type-level naturals, I've defined an n-dimensional grid. {-# LANGUAGE
I have a list view that is displaying data using the gridview. This list
My typical form with Grid look like this in XAML: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width=Auto></ColumnDefinition>
A typical C program would be compiled, assembled, linked and loaded. I know that
I have a rendering application that renders lots and lots of cubes in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.