Flexsheet Sort after Inserting row

Posted by: kuhnimanagam_raznin on 4 August 2018, 3:24 am EST

  • Posted 4 August 2018, 3:24 am EST

    Hi Team,

    I am trying to add a row to my flexsheet using custom ‘add’ code as follows:

    active_sheet.insertRows(selectedRow);

    var newrow = //A custom row with some default values

    active_sheet.itemsSource.splice(selectedRow - 1, 1, newrow);

    Which works well.But after Sorting the default values disappear.

    I tried with one of your samples where you are adding the new row to the items collection of itemsSource like -

    active_sheet.itemsSource.items.splice(selectedRow - 1, 1, newrow); This gives me error as I don`t see items property in itemsSource.

    In my case I am creating Flexsheet object using

    new wjmo.grid.sheet.Flexsheet(#Id); and adding a bound sheet with observable array

    as data soruce.

    Can you please help me with this.

    Thanks,

    Raznin

  • Posted 5 August 2018, 11:31 pm EST

    Hi,

    The process of rows recording (operations such as inserting/deleting/sorting ) are some complex as they include various other calculations like formula update thus flexsheet maintains its internal source to facilitate these operations and it is advised to use only methods provided by the flexsheet to update the source.

    To insert the rows you may use insertRows() method.

    Please refer to the following code snippet:-

    
    function insertItemAtIndex(flexsheet,index,item){
    
    
    flexsheet.insertRows(index);
    
    
    let row=flexSheet.rows[index+1];
    
    
    Object.assign(row.dataItem,item);
    
    
    }
    
    

    You may also refer to the following sample:-

    https://stackblitz.com/edit/js-tyzzke?file=index.js

    ~Manish

  • Posted 6 August 2018, 3:38 pm EST

    Hi Manish,

    Thanks for your quick response!

    I tried with the sample you provided and it maintains the default values after Sorting.

    1 ) I am also formatting the sheet by painting its cells.So each time I add an new row,based on the new range I am calling the format function to paint the sheet using applycellsStyles method.This works fine the first time I add a row and Sort.The second time I again add a row and after sorting it loses the format. I even tried calling the format function again in the collectionChanged event to repaint the sheet,which is not working either.Am I missing something here.

    2)I notice that in a bound sheet after filtering,if I add a new row the row is not seen until I clear the filter.In this case also i see that the newly added row does`nt keep the color format.

    Thanks,

    Raznin

  • Posted 9 August 2018, 1:45 pm EST

    Hi,

    We are sorry for the delayed response.

    We were able to replicate the issue at our end and hence the issue has been forwarded to the concerned team for further investigation with tracking id 338168 and 338170.

    We will let you know for any updates on this.

    ~Manish

Need extra support?

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

Learn More

Forum Channels