Issues with ListGridFieldType.BOOLEAN and non-boolean database values

Hello everyone!

SmartGWT Version: 2.5

I am trying to create a listgrid containing editable checkboxes. Following the SmartGWT-Showcase I use this statement

field.setType(ListGridFieldType.BOOLEAN)

in order to show a checkbox in the listgrid.

Unfortunately, in our database (Oracle) boolean values stored as -1 (true) and 0 (false). Thus I use a custom SELECT-statement in the datasource with an decode-statement to receive true and false instead of -1 and 0:

decode(sk_is_bookable, -1, true, false) as sk_is_bookable_bool.

This works fine so far. The trouble starts trying to save the changed values.
To make sure the database get the right values, I use the following:

field.setEditValueParser(new CellEditValueParser() { // parsing });

The parsing also works fine, but when listgrid.saveAllEdits() is called, the criteria of the SQL-Statement are all messed up. Instead of updating just the edited row, a SELECT COUNT(*) with SK_IS_BOOKABLE = ‘-1’ is called resulting in a stack-overflow-exception.

Any suggestions?

All you need to do is set sqlStorageStrategy on the field. Remove all your other customizations that you made to try to do this since you seem to have messed something up, probably you have ended up using a select statement as you update operation or similar.

Is there any way to create a custom sqlStorageStrategy?
I need to save true as ‘-1’ and false as ‘0’. Unfortunately none of the provided
strategies fits.

Yes, see the QuickStart Guide, Server Framework chapter - search for sqlStorageStrategy and alternative approaches are explained right there.