jQWidgets Forums

jQuery UI Widgets Forums Grid When to use autoresizecolumns with virtualmode

This topic contains 1 reply, has 2 voices, and was last updated by  Hristo 5 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • jqwidgetuser
    Participant

    With the grid defined as:

    <jqxGrid #myGrid 
      [width]="800"
      [source]="dataAdapter"
      [columns]="columns"
      [autoheight]="true"
      [pageable]="true"
      [virtualmode]="true"
      [rendergridrows]="rendergridrows">
    </jqxGrid>

    and

    export class AppComponent {
      @ViewChild('myGrid', { static: false }) myGrid: jqxGridComponent;  
      source: any =
      {
        datatype: 'json',
        datafields: [],
        url: 'http://localhost/getrows',
        cache: false,
        root: 'Rows',
        beforeprocessing: (data: any) => {
          this.source.totalrecords = data.TotalRows;
        }
      };
    
      dataAdapter: any = new jqx.dataAdapter(this.source);
    
      columns: any[] =
        [
          { text: 'First Name', datafield: 'first_name', width: 250 },
          { text: 'Last Name', datafield: 'last_name', width: 150 }
        ];
    
      rendergridrows = (params: any): any => {
        return params.data;
      }
    }

    I would like to resize the columns with

    this.myGrid.autoresizecolumns();

    Where should I insert this command in order to resize the columns after the grid downloads the data from 'http://localhost/getrows' url. I tried to use this autoresizecolumns command into the rendergridrows method. But the resizing there happens too soon since the Binding is not yet Completed in the rendergridrows method.


    Hristo
    Participant

    Hello jqwidgetuser,

    You could implement the loadComplete callback of the jqxDataAdapter.
    This and more suitable information you could find out in the API Documentation page:
    https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxdataadapter/jquery-data-adapter.htm?search=dataadapter
    Also, you could use the setTimeout option, too.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.