I have to produce an editable listGrid for a well known set or records that could initially have invalid data.
The user should be able to notice invalid contents and edit cells accordingly in order to correct and save data.
The problem is that the listgrid doesn't show error messages nor error icons until the user tries to edit a cell (even if its contents are already invalid). Only after changing cell contents to a new invalid value the error marker remains visible.
I've tried almost every combination I can think of, loading invalid data on a clientonly datasource, and even adding directly to the listgrid, disabling autosave and also setting saveLocally: no results.
Is there any way to load invalid data on an editable listgrid somewhat marking all invalid cells (possibly with error message tooltips)?
Here you are an example snippet:
I'd also need to set ListGrid.setAlwaysShowEditors (true) but it seems to make things worse (that way invalid contents markers are shown only on focused rows).
[ATTACH]4677[/ATTACH] is a complete test case entry point.
Tried with SmartGWT 3.0 [SmartClient Version: v8.2p_2012-10-16/LGPL Development Only (built 2012-10-16)]
The user should be able to notice invalid contents and edit cells accordingly in order to correct and save data.
The problem is that the listgrid doesn't show error messages nor error icons until the user tries to edit a cell (even if its contents are already invalid). Only after changing cell contents to a new invalid value the error marker remains visible.
I've tried almost every combination I can think of, loading invalid data on a clientonly datasource, and even adding directly to the listgrid, disabling autosave and also setting saveLocally: no results.
Is there any way to load invalid data on an editable listgrid somewhat marking all invalid cells (possibly with error message tooltips)?
Here you are an example snippet:
Code:
final DataSource dataSource = new DataSource (); dataSource.setClientOnly (true); final ListGrid grid = new ListGrid (); grid.setAutoFetchData (true); grid.setCanEdit (true); grid.setAutoSaveEdits (false); grid.setValidateByCell (true); grid.setEditEvent (ListGridEditEvent.CLICK); final List<Record> testData = new ArrayList<Record> (); {//data initialization { final Record record = new Record (); record.setAttribute ("id", "1"); record.setAttribute ("budgetA", "asdf"); record.setAttribute ("budgetB", 123d); record.setAttribute ("foo", "fooXYZ"); testData.add (record); } { final Record record = new Record (); record.setAttribute ("id", "2"); record.setAttribute ("budgetA", 789); record.setAttribute ("foo", "qwerty"); testData.add (record); } } grid.addDrawHandler (new DrawHandler() { @Override public void onDraw (DrawEvent event) { if (grid.isDrawn ()) { GWT.log ("adding live data"); for (Record record : testData) { grid.addData (record); } } else { GWT.log ("data add SKIPPED!!!"); } } }); {//datasource fields initialization final DataSourceTextField keyField = new DataSourceTextField ("id", "ID"); keyField.setPrimaryKey (true); final DataSourceFloatField budgetAField = new DataSourceFloatField ("budgetA", "Budget A"); final DataSourceFloatField budgetBField = new DataSourceFloatField ("budgetB", "Budget B"); { final Validator myValidator = new CustomValidator() { @Override protected boolean condition (Object value) { GWT.log ("budgetB validation value: "+value); if (value==null) { GWT.log ("budgetB is not valid: "+value); setErrorMessage ("The value is mandatory"); return false; } return true; } }; budgetBField.setValidators (myValidator); } final DataSourceTextField fooField = new DataSourceTextField ("foo", "Foo"); { final Validator myValidator = new CustomValidator() { @Override protected boolean condition (Object value) { if (value==null) { setErrorMessage ("The value is mandatory"); return false; } if (!(value instanceof String)) { setErrorMessage ("Only textual values admitted"); return false; } if (!((String)value).startsWith ("foo")) { setErrorMessage ("Should start with 'foo'"); return false; } return true; } }; fooField.setValidators (myValidator); } dataSource.setFields (keyField, budgetAField, budgetBField, fooField); } { final ListGridField budgetAField = new ListGridField ("budgetA", "Budget A (float)"); final ListGridField budgetBField = new ListGridField ("budgetB", "Budget B (mandatory, float)"); final ListGridField fooField = new ListGridField ("foo", "Foo (mandatory, and should start with 'foo')"); grid.setFields (budgetAField, budgetBField, fooField); } grid.setDataSource (dataSource); ...
[ATTACH]4677[/ATTACH] is a complete test case entry point.
Tried with SmartGWT 3.0 [SmartClient Version: v8.2p_2012-10-16/LGPL Development Only (built 2012-10-16)]
Comment