How to validate data by the use of commands through code directly. [message #1220487] |
Thu, 12 December 2013 07:24 |
SD Khan Messages: 63 Registered: May 2013 |
Member |
|
|
Hi Dirk !
I have a cell which is editable and attached display converter and data validators to it now, when i click on the cell and type some invalid value it works fine and validator mark value as RED and don't allow to commit.
So Now,
I want's to achieve the same behavior through the code like when some button is pressed, my cell becomes editable and if the passed values is not valid, then it should mark it as red and don't allow to commit.
I have tried several things, like first called EditCellCommand, which bring my cell in the inline edit mode, now i called updateCellCommand , which trys to commit wrong value, but instead of showing the error and marking the wrong value as red, it does nothing.
What are the required steps needed to achieve this behavior ?
Thanks,
SD Khan
|
|
|
|
Re: How to validate data by the use of commands through code directly. [message #1220528 is a reply to message #1220494] |
Thu, 12 December 2013 11:18 |
SD Khan Messages: 63 Registered: May 2013 |
Member |
|
|
Yup, right , I have done following steps
1. Called edit cell command
EditCellCommand cmd = new EditCellCommand(getTable().getNatTable(), getTable().getConfigRegistry(), cell);
getTable().getNatTable().doCommand(cmd);
2.Get active cell editor
ICellEditor editor = ActiveCellEditorRegistry.getActiveCellEditor();
3. Set the text you want to set
editor.setEditorValue("wow");
4.Now, validate
editor.validateCanonicalValue(editor.getEditorValue(), new RenderErrorHandling(new ControlDecorationProvider(FieldDecorationRegistry.DEC_ERROR)));
Now, if the text is invalid, it will remain in the edit mode and will be marked as red.
But his behavior can only be achieved for text cell editors.
[Updated on: Thu, 12 December 2013 11:19] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02847 seconds