Auto-size column width and remove row header

Posted by: oskarputraa on 19 August 2019, 10:44 am EST

    • Post Options:
    • Link

    Posted 19 August 2019, 10:44 am EST - Updated 3 October 2022, 10:38 am EST

    Hi,

    I’ve implemented remove row header and auto size column width function but not working. It still have default column width size and my row header still visible.

    What I want is auto size column width for column A, B, C and remove this column header.

    this is my code

    Could you help ? Thanks.

    Oskar Putra

  • Posted 19 August 2019, 11:11 am EST

    Hi,

    this.formatSheet.rows[0].visible = false 
    

    This code work well if I’m not do async http post to get datasource from my database.

    Oskar Putra

  • Posted 19 August 2019, 3:08 pm EST

    Hi Oskar,

    The reason that the row becomes visible and the columns go back to their default after the data is loaded asynchronously is that when the source is changed, the rows and the columns are recreated.

    To solve this, assign an empty CollectionView as the source of the Sheet and handle its sourceCollectionChanged event. In this event handler, hide the header row and auto-size the columns.

    When your source is loaded asynchronously, then assign this as the sourceCollection of the CollectionView instance. Please refer to the code snippet below and the sample for reference:

    var self = this;
    self.source = new wjcCore.CollectionView([], {
          sourceCollectionChanged: function (s, e) {
            if (self.formatSheet) {
              self.formatSheet.rows[0].visible = false;
              self.formatSheet.autoSizeColumns(0, 2);
            }
          }
    });
    wjcCore.httpRequest('https://api.myjson.com/bins/1130if', {
          method: 'GET',
          success: function (xhr) {
            self.source.sourceCollection = (JSON.parse(xhr.responseText));
          }
    })
    

    https://stackblitz.com/edit/angular-i1z2j6

    Regards,

    Ashwin

Need extra support?

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

Learn More

Forum Channels