• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Expand or Collapse All Groups - Data Grid

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Expand or Collapse All Groups - Data Grid

    Good afternoon! I'm working with a data grid widget with grouping enabled. My grid looks great with the part numbers expanded and all the detail rows showing under each part. I would like to set up buttons to allow users to collapse all groups or expand all groups. I know Pivot Grids have app variables I can set, but I can't seem to find something like that for regular grids.

  • #2
    This is currently only possible using the "Execute Script" behavior. However, we will make this available in the upcoming Valence 6.1. We will allow you to link an app variable to control the expand/collapse.

    Comment


    • #3
      I'm not sure what the type would be here. To do this with pivot grids I could do:

      var thisGrid = getWidget('widgetNum');

      thisGrid.down('pivotgrid').collapseAll();

      success();

      I tried looking at https://examples.sencha.com/extjs/7..../#grouped-grid but I'm a little lost here.

      Comment


      • #4
        Hi,

        This one isn't as straight forward so it will be good to have it as an app variable in 6.1

        Below is an example script and I named my widget myWidget and this will collapseAll however if you want to expandAll just change the value of the fnc variable to 'expandAll'

        Code:
        var myWidget = getWidget('myWidget'),
            grid     = myWidget.down('grid'),
            view     = grid.getView(),
            features = (view.features) ? view.features : [],
            fnc      = 'collapseAll', // or could be 'expandAll'
            grouping, ii;
        
        // get the grouping feature
        //
        for (var ii = 0; ii < features.length; ii++) {
            if (features[ii].ftype === 'grouping' || features[ii].ftype === 'groupingsummary') {
                grouping = features[ii];
                break;
            }
        }
        
        // if grouping feature found then collapseAll/expandAll based on
        //  the value of fnc
        //
        if (!Valence.isEmpty(grouping) && typeof grouping[fnc] === 'function') {
            grouping[fnc]();
        }
        
        success();

        Comment


        • #5
          Like magic! Thank you Johnny, this works beautifully.

          Comment

          Working...
          X