How to get the old value, new value of the cell of flexgird v4.0.30319

Posted by: levanduyet on 10 March 2023, 3:08 am EST

    • Post Options:
    • Link

    Posted 10 March 2023, 3:08 am EST

    Hi,

    I use flexgrid v4.0.30319, I want to check the old value of the cell and compare with the new value of the cell.

    After that I will compare and allow to change or change back to the old value.

    How I can do that. I have try event BeforeEdit to save the old value

    sOldValue=flex[flex.Row,2]

    Then in the Event LeaveEdit, I get new value. But look like I could not get the old value from event BeforeEdit

    Thanks,

    Duyet Le

  • Posted 12 March 2023, 7:19 pm EST

    Hi,

    “BeforeEdit” is a bit dangerous, as it is also fired when rendering the cell - it might happen that you store a value of a different cell because of this behavior. Better use the “StartEdit” event to save the original value. This event is fired when the cell enters edit mode.

    Hope this helps

    Wolfgang

  • Posted 12 March 2023, 9:33 pm EST

    Hello Duyet,

    As suggested by Wolfgang, You can use the StartEdit and AfterEdit events of FlexGrid to achieve your requirement.

    Please find the attached sample implementing the same.

    @Wolfgang, thanks for your insights.

    Regards,

    Prabhat Sharma.

    EditDemo.zip

  • Posted 14 March 2023, 3:20 am EST

    Thanks @Wolfgang & Prahat Sharma.

    I were use ValidateEdit.

    In this event, if I use

    flex[e.Row, e.Col] //=> Value before edit.


    And if I use
    flex.Editor.Text //=> The value that the user has enter

    The BeforeEdit just to define which column that the user can edit

    
    if (flex.Col != 11)
                        e.Cancel = true;


    Duyet Le

  • Posted 14 March 2023, 8:51 pm EST

    Hello Duyet,

    Thanks for explaining your use case.

    I hope the issue has been resolved on your end. In case you need any help from our end, please feel free to ask.

    Regards,

    Prabhat Sharma.

Need extra support?

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

Learn More

Forum Channels