Always auto size rows by default

Posted by: tie_entwicklung on 27 June 2019, 5:29 am EST

    • Post Options:
    • Link

    Posted 27 June 2019, 5:29 am EST

    Hi

    Until now I’ve used flexGrid.autoSizeRows(); to fix row heights after resizing a column, sorting, filtering, etc. This is very annoying to do manually.

    Is there an option to always adjust row heights automatically?

    Thanks

  • Posted 27 June 2019, 11:33 pm EST

    Hello,

    You may call the autoSizeRows method in the loadedRows event of FlexGrid. This will cause the rows to be auto-sized whenever the rows are loaded again like after sorting or filtering. Please refer to the code snippet below for reference:

    var grid = new wjcGrid.FlexGrid('#grid', {
      loadedRows: function (s, e) {
        s.deferUpdate(() => {
          s.rows.forEach(row => {
            row.multiLine = true; // rows get recreated so we have to change their multiLine property
          });
          s.autoSizeRows();
        });
      },
      itemsSource: getData(),
    });
    
    

    You may also refer to the sample below:

    https://stackblitz.com/edit/js-wrnur8

  • Posted 28 June 2019, 2:52 am EST

    Your solution has worked in all cases except when resizing a column. This brings it down to two event handler which is acceptable. Thank you!

Need extra support?

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

Learn More

Forum Channels