Commit Flexgrid data without changed cell focus

Posted by: deepak.dubey on 2 June 2020, 9:58 am EST

    • Post Options:
    • Link

    Posted 2 June 2020, 9:58 am EST

    Hi,

    I want to commit our edit cell data of flexgrid without removing cell focus.

    I used javascript and wijmo.

    I already try these things but not worked.

    componentObject.grid.finishEditing();

    componentObject.grid.commitEdit();

    and then save flexgrid data with trigger our save button

    componentObject.submitBtn.trigger(‘click’);

    Deepak Dubey

  • Posted 3 June 2020, 3:17 am EST

    Hi Deepak,

    You may handle the cellEditEnding event and call the collectionView’s commitEdit method:

    grid.cellEditEnded.addHandler((s, e) => {
      grid.collectionView.commitEdit();
      btn.click(); // click the button automatically
    });
    

    Regards,

    Ashwin

  • Posted 3 June 2020, 11:51 am EST

    Hi Ashwin,

    Thanks to reply.

    I used this but this code work when my cell focus is move on to other cell.

    but I want to save my changed data using short cut key and for that I am triggering our save button on pressing keys, So when we edit the cell and press our custom key alt+s to submit our change without changing cell focus.

    So I used

    componentObject.grid.finishEditing();

    componentObject.grid.collectionView.commitEdit();

    setTimeout(function(){

    componentObject.submitBtn.trigger(‘click’);

    },100);

    and its working fine but we its work on every cell focus where I didn’t change any cell value.

    waiting your reply…

    Regards

    Deepak Dubey

  • Posted 3 June 2020, 12:05 pm EST

    Hi Ashwin,

    Have any short cut key to wrap text of flexgrid cells.

    Regards

    Deepak Dubey

  • Posted 4 June 2020, 1:49 am EST

    Hi Deepak,

    I am sorry but I do not understand your issue properly. Can you please explain what are you referring to by this line:

    and its working fine but we its work on every cell focus where I didn’t change any cell value.

    It seems that your issue is that the commitEdit method works for each cell regardless of whether you have edited it or not. But, if you have not edited any cell and the commitEdit method is called, then this is not an issue because the data will not be updated because you are not editing anything. Infact, the commitEdit method checks whether an item is being edited and then only proceeds to commit it.

    Regarding the word wrap, just add a keydown event listener and get the currently selected column and toggle is wordWrap property. Please refer to the sample link below:

    https://stackblitz.com/edit/js-3p129f

    ~regards

  • Posted 4 June 2020, 6:00 am EST

    Hi Ashwin,

    Actually we have two cases.

    1. We edit cell value and without loss cell focus press key alt+cntrl+c and execute this code

      componentObject.grid.finishEditing();

      componentObject.grid.collectionView.commitEdit();

      setTimeout(function(){

      componentObject.submitBtn.trigger(‘click’);

      },100);

    and we get alert of msg that Your data save sucessfully.

    which is working fine.

    1. when we select a cell its gone in edit mode and without any change we press key to save, its also hit our code and get alert msg which is seems like its hit our db request. In this case we dont want to hit that code because I am not change any data.

    So is any method which detect that has any change in grid or not and if is any change in our grid then commit method call

    Thanks

    Regards

    Deepak Dubey

  • Posted 5 June 2020, 4:14 am EST

    Hi Deepak,

    Thank you for the clarification. I understand you requirements now. For this, you may use the itemsEdited array of CollectionView. This array will only be updated when a new edited item is added or an already edited item is updated.

    First, you need to set the trackChanges property of the CollectionView to true and then handle the collectionChanged event of itemsEdited array. Please refer to the updated sample below:

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

    ~regards

Need extra support?

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

Learn More

Forum Channels