v7.3.0

RowExpander
Feature

Enables expanding of Grid rows by either row click or double click, or by adding a separate Grid column which renders a button that expands or collapses the row.

The content of the expanded row body is rendered by providing either a renderer function to the rowExpander feature config:

new Grid({
   features : {
       rowExpander : {
           renderer({record, region, expanderElement}){
               return htmlToBeExpanded;
           }
       }
   }
});

Or a widget configuration object:

new Grid({
   features : {
       rowExpander : {
           widget : {
               type : 'detailGrid',
           },
           dataField : 'orderDetails'
       }
   }
});

Note that if used in a Gantt, the Gantt's fixedRowHeight must be set to false.

This feature is disabled by default

Keyboard shortcuts

This feature has the following default keyboard shortcuts:

Keys Action Action description
Shift+ArrowRight expandByKey Expands the focused row
Shift+ArrowLeft collapseByKey Collapses the focused row
Space toggleExpandByKey Toggles expand/collapse when focused on the expander cell

Please note that Ctrl is the equivalent to Command and Alt is the equivalent to Option for Mac users

For more information on how to customize keyboard shortcuts, please see our guide

Expand on click

Set triggerEvent to a Grid cell event that should trigger row expanding and collapsing.

new Grid({
   features : {
       rowExpander : {
           triggerEvent: 'celldblclick',
           renderer...
       }
   }
});

Expander column position

The expander column can either be inserted before or after the existing Grid columns. If the Grid has multiple regions the column will be added to the first region.

Adjust expander column position to last in a specific Grid region by setting columnPosition to last and configuring the column with a region name.

new Grid({
   features : {
       rowExpander : {
           column: {
               region: 'last'
           },
           columnPosition: 'last',
           renderer...
       }
   }
});

Record update

If the expander content depends on row record data, the expander can be re-rendered on record update by setting refreshOnRecordChange to true.

new Grid({
   features : {
       rowExpander : {
           refreshOnRecordChange: true,
           renderer...
       }
   }
});

Async

When the content of the row expander should be rendered async just see to it that you return a promise.

new Grid({
   features : {
       rowExpander : {
           async renderer({record, region, expanderElement}){
               return fetchFromBackendAndRenderData(record);
           }
       }
   }
});

Multiple regions

When the Grid has more than one region, the renderer function will be called once per region for each expanding row.

new Grid({
   features : {
       rowExpander : {
           renderer({ record, region }) {
               if(region === 'locked') {
                   return createRowExpander(record);
               }

return null; } } } });

If you are using the widget configuration, you can provide a widget configuration object for each region like so:

new Grid({
   features : {
       rowExpander : {
           widget : {
               locked : {
                   type : 'detailGrid',
                   // If your widgets uses different data sources, put the
                   // dataField property in the widget configuration object
                   dataField : 'orderDetails'
               },
               normal : {
                   type : 'summaryGrid',
                   dataField : 'sumDetails'
               }
           }
       }
   }
});

This live demo has a set of buttons in the locked region and a detail grid in the normal region:

If you want your expanded content to span over all Grid regions, set the spanRegions config to true.

See also

  • Grid - The grid component
No results

Configs

Configs are options you supply in a configuration object when creating an instance of this class
  • When expanding a row and the expanded body element is not completely in view, setting this to true will automatically scroll the expanded row into view.

  • columnPosition : 'first'/'last'first

    Makes the expand/collapse button column appear either as the first column (default or first) or as the last (set to last). Note that the column by default will be added to the first region, if the Grid has multiple regions. Use the column config to change region.

  • Used together with widget to populate the widget's Store from the expanded record's corresponding dataField value, which needs to be an array of objects or a store itself.

  • Use this to disable expand and collapse animations.

  • See Keyboard shortcuts for details

  • Use this for customizing async renderer loading indicator height.

  • Use this for customizing async renderer loading indicator text.

  • If set to true, the RowExpander will, on record update, re-render an expanded row by calling the renderer function or recreate the configured widget.

  • When the Grid has multiple regions, setting this config to true changes how the expanded content is created and rendered. Instead of calling renderer once per region (or one widget per region) it will only create one expanded element which will span the full grid width regardless of Grid regions.

Properties

Properties are getters/setters or publicly accessible variables on this class

Functions

Functions are methods available for calling on the class
    • collapseByKey( )
      private

      Collapses the focused row on Shift+ArrowLeft.

    • expandByKey( )
      private

      Expands the focused row on Shift+ArrowRight.

    • toggleExpandByKey( )
      private

      Toggles expand/collapse when focused on the expander column cell. Only activates when the focus is on the expander column to avoid conflicts with other Space handlers.

    • beforeRenderRow( )
      private

      Hooks on before row render to render or remove row expander content depending on record state.

    • internalRender( )
      private

      Re-renders the grid from the topmost record of those saved in bufferedRenderer

    • scrollRowIntoView( )
      private

      Scrolls expanded row into view. This function is called after rowManager has finished rendering.

    • waitForTransition( )
      private

      Waits for height transition on the provided rows element. Then calls provided function.

    Events

    Events are triggered for certain actions in this class and can be listened for to react to those actions in your code

    Event handlers

    Event handlers are callbacks called as a result of certain actions in this class

    CSS variables

    CSS variables that can be set to adjust appearance
    Name Description
    --b-row-expander-background Row expander body's background color
    --b-row-expander-border-bottom-color Row expander body's border bottom color
    --b-row-expander-border-bottom-width Row expander body's border bottom width
    --b-row-expander-color Row expander body's color
    --b-row-expander-font-weight Row expander body's font weight
    --b-row-expander-padding Row expander body's padding
    id: rowExpander

    Source path

    Grid/feature/RowExpander.js

    Contents