CollectionView Refresh does not work

Posted by: krish.balaji on 3 May 2018, 3:54 am EST

    • Post Options:
    • Link

    Posted 3 May 2018, 3:54 am EST

    Hi,

    	var range = this.flex.selection;
    	var index = range.row;
    	var item = this.flex.collectionView.items[index];
    	item['amount'].push({var:0});
    	item['idIndicator'].push({var:'One'});
    	this.flex.collectionView.refresh();
    	this.flex.autoSizeRow(range.row);
    

    I am trying to add items to the collectionview and use “refresh” method to refresh the grid. Grid does not refresh consistently.

    Please find attached my code. I have added this code to “AddStep” method on the context menu.

    Thanks

  • Posted 3 May 2018, 3:54 am EST

  • Posted 3 May 2018, 9:35 pm EST

    Hi,

    The problem seems to be with row height rather than the refresh.

    When you refresh the grid,the rows are loaded again with the default height.

    To fix this problem you can handle the loadedRows event and call the autoSizeRow() method to resize the row.

    //refer to following code snippet

    <wj-flex-grid #flex
                [wjContextMenu]="ctmenu"
                [selectionMode]="'Row'"
                [itemFormatter]="itemFormatter"
                [stickyHeaders]="false"
                [keyActionTab]="'Cycle'"
                [itemsSource]="data"
                [allowDragging]="'Both'"
                [autoScroll]="true"
                (loadedRows)="autoSizeFlexRows(flex)"
                (initialized)="init(flex)">
    /*then in autoSizeFlexRows() method */
    autoSizeFlexRows(flex){
                flex.rows.forEach((row,rowIndex) => {
                    var data=row.dataItem;
                    if(data.amount.length>1||data.idIndicator.length>1){
                        flex.autoSizeRow(rowIndex);
                    }
                });
    }
    

    Also find the attached updated sample.

  • Posted 3 May 2018, 9:35 pm EST

Need extra support?

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

Learn More

Forum Channels