1. SmartClient Version: SC_SNAPSHOT-2011-12-05/PowerEdition Deployment (built 2011-12-05)
2. I test against IE8 and IE7
6.
I have the follwoing datasource
I use this data-source in my ListGrid for which I override the CellFormater, CellEditValueFormater and CellEditValueParser because i need German formatting for the values
The EditValueParser sees the value exactly as it is entered but the CellFormatter's format method gets a rounded value passed into it. Thats why i have to get the value from record.
When I input a value that only has a small difference, like 0.02 the EditComplete handler is not called. Thats because the value is again rounded and might match the previous value.
My workaround is to catch the new value when it's parsed in a state variable and set it in the EditorExit handler on the edited record.
The ListGrid.setEditValue does not work. This methods takes the value it gets, and rounds the value again. The value is sent to my EditValueParser where you can see that the value Object has the rounded value. WTF?
This looks like a bug.
2. I test against IE8 and IE7
6.
I have the follwoing datasource
Code:
<DataSource xmlns="http://www.smartclient.com/schema" schema="PNLP" dbName="WOLF_DB" tableName="PNL_OVERVIEW" ID="pnlOverview" dataSourceVersion="1" serverType="sql" > <fields> <field name="PNL_OVERVIEW_ID" type="sequence" hidden="true" primaryKey="true" sequenceName="PNL_OVERVIEW_ID_SEQ" /> <field name="DESK" type="text" canEdit="false" width="140" /> <field name="DESK_GROUP" type="text" canEdit="false" width="140" /> <field name="DESK_CURRENCY" type="text" hidden="false" canEdit="false" width="85" /> <field name="SWING" type="number" canEdit="false" width="85" /> <field name="MTD" type="number" canEdit="false" width="85" /> <field name="YTD" type="number" canEdit="false" width="85" /> <field name="MANUAL_YTD" type="number" canEdit="false" width="85" /> <field name="FINAL_SWING" type="number" width="85" /> <field name="FINAL_MTD" type="number" canEdit="false" width="85" /> <field name="FINAL_YTD" type="number" width="85" /> <field name="DATE_SWING" type="date" hidden="true" /> <field name="DATE_MTD" type="date" hidden="true" /> <field name="DATE_YTD" type="date" hidden="true" /> <field name="SNAPSHOT_DATE" type="date" hidden="true" /> <field name="EXPORT_DATE" type="date" hidden="false" canEdit="false" width="120" /> </fields> <operationBindings> <operationBinding operationType="fetch"> <selectClause>PNL_OVERVIEW_ID, pnl_overview.DESK, pnl_overview.DESK_GROUP, SWING, MTD, YTD, MANUAL_YTD, FINAL_SWING, FINAL_MTD, FINAL_YTD, DATE_SWING, DATE_MTD, DATE_YTD, SNAPSHOT_DATE, EXPORT_DATE, pnl_overview_desk_group.DESK_CURRENCY</selectClause> <tableClause>pnl_overview join pnl_overview_desk_group on pnl_overview.desk = pnl_overview_desk_group.desk and pnl_overview.desk_group = pnl_overview_desk_group.desk_group</tableClause> </operationBinding> </operationBindings> </DataSource>
Code:
final private CellEditValueParser cellEditValueParser = new CellEditValueParser() { @Override public Object parse(Object value, ListGridRecord record, int rowNum, int colNum) { if (value == null) { return null; } try { NumberFormat nf1 = NumberFormat.getDecimalFormat(); Double parsedValue = nf1.parse(value.toString()); currentEditValue = parsedValue; return parsedValue; } catch (Exception e) { return value.toString(); } } }; final private CellFormatter cellFormatter = new CellFormatter() { @Override public String format(Object value, ListGridRecord record, int rowNum, int colNum) { return formatCellValue(value, record, colNum); } }; final private CellEditValueFormatter cellEditValueFormatter = new CellEditValueFormatter() { @Override public String format(Object value, ListGridRecord record, int rowNum, int colNum) { return formatCellValue(value, record, colNum); } }; private String formatCellValue(Object value, ListGridRecord record, int colNum) { if (value == null) { return null; } DateTimeFormat df = DateTimeFormat.getFormat("dd.MM.yyyy hh:mm"); NumberFormat nf = NumberFormat.getFormat("#,##0.00"); if (value instanceof Date) { Date date = (Date) value; return df.format(date); } if (value instanceof Number) { // value is not accurate enough, it's rounded. must use value from record String fieldName = detailsGrid.getFieldName(colNum); Double d = record.getAttributeAsDouble(fieldName); return nf.format(d.doubleValue()); } return value.toString(); }
When I input a value that only has a small difference, like 0.02 the EditComplete handler is not called. Thats because the value is again rounded and might match the previous value.
My workaround is to catch the new value when it's parsed in a state variable and set it in the EditorExit handler on the edited record.
Code:
listGrid.addEditorExitHandler(new EditorExitHandler() { @Override public void onEditorExit(EditorExitEvent event) { Record record = event.getRecord(); String fieldName = listGrid.getFieldName(event.getColNum()); previousEditValue = record.getAttributeAsDouble(fieldName); if (currentEditValue.doubleValue() == previousEditValue.doubleValue()) { return; } record.setAttribute(fieldName, currentEditValue); } }); listGrid.addEditCompleteHandler(new EditCompleteHandler() { @Override public void onEditComplete(final EditCompleteEvent event) { if (currentEditValue.doubleValue() == previousEditValue.doubleValue()) { return; } // some more code } });
This looks like a bug.
Comment