FlexGrid Validation with REST API Angular 2

Posted by: stefan-glawischnig on 14 September 2017, 12:03 pm EST

    • Post Options:
    • Link

    Posted 14 September 2017, 12:03 pm EST

    Hello,

    is there a recommended solution to validate flex grid input on row and/or cell level?

    The workflow is as followed: The user enters a value and on the on the onCellEditEnding event the input should be sent to a server and a validation result comes back as a promise or observable. If an error occurs, the cell should be highlighted. The validation cannot be hardcoded, it is checked in the backend

    I tried two solutions which both don’t really work for me:

    • The getError() method of the collection view. I have very large datasets, and if a change occurs, every property of every item is evaluated. So this does not work for me.
    • The gridItemFormatter().

    I tried to cancel the onCellEditEnding event and continue when the validation promise is resolved, but this does not work obviously.

    Is there a solution to make a flexgrid event wait until some async work is done?

    I’m really struggling here, so any help is greatly appreciated!

    Best regards,

  • Posted 14 September 2017, 12:03 pm EST

    Hi,

    For this, you need to call service for validation in cellEditEnding event and service return error, store cell position in a array. Using this array, highlight cell using itemFormatter.

    For your reference, please see the fiddle that implements the same.

    If you would like to update cell value on server, please see the fiddle that implements the same.

    Thanks,

    Manish Kumar Gupta

  • Posted 14 September 2017, 12:03 pm EST

    Dear Manish Kumar Gupta,

    thank you for the clarification that is also the solution that I implemented.

    Too bad, it’s not possible to tell the grid to wait for an async call, but you can’t have everything :wink:

  • Posted 14 September 2017, 12:03 pm EST

    Hi Stefan,

    If you try the suggested solution for highlighting Cell, it is async process for highlighting cell. You can edit FlexGrid untill validation is performing on server.

    Yes, No-one is perfect in this world same as a control can’t have each feature :slight_smile: Still we try to cover most of feature directly or indirectly.

    Thanks,

    Manish Kumar Gupta

  • Posted 10 December 2020, 9:20 am EST

    Hi Manish, I am going through the same situation.

    If we store a cell position and use that into itemFormatter function to display an indication, then what happens if the user sorts the data on the grid and the cell positions will get changed. Is there any way to handle that?

    Thanks

  • Posted 11 December 2020, 7:24 am EST

    Hi Chhavi,

    The mentioned use case is already handled by the fiddle solution provided by manish. http://jsfiddle.net/mkgupta911/uLap4moz/19/

    In the above fiddle, instead of simply just storing the row and column index, the data item is also saved to keep track of required cells even if their position is changed.

    Regards

Need extra support?

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

Learn More

Forum Channels