Show Empty Collection Indicator

Posted by: tie_entwicklung on 29 November 2018, 11:23 am EST

    • Post Options:
    • Link

    Posted 29 November 2018, 11:23 am EST - Updated 3 October 2022, 8:16 pm EST

    Hi,

    Is there a way to display a special row in case there are no items in the source collection? Something in the way of “no items” to show the difference between a failure to fetch and actually empty data.

    I could hack my way to it but maybe there’s already an existing solution? :slight_smile:

    Thank you.

  • Posted 3 December 2018, 2:32 am EST

    Hi,

    There is no direct property or method to do so, however, you may handle the loadedRows event and append an extra row if there is no row to display.

    You may refer to the following code snippet and sample:

    loadedRows(grid){
    
        if(!grid || !grid.collectionView || grid.collectionView.items.length){
          return;
        }
    
        // loaded rows add additional
        let item = {};
        grid.columns.forEach(col => {
          item[col.binding] = 'No items to display';
        });
        let row = new wjcGrid.Row(item);
        row.allowMerging = true;
        row.isReadOnly = true;
        grid.rows.push(row);
      }
    

    https://stackblitz.com/edit/angular-xuatrt?file=src%2Fapp%2Fapp.component.ts

    ~Sharad

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels