Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Converting MySQL integer to checkbox

    Hi,

    I managed to get my MySQL DB accessed by SmartGWT. In my database I have two fields that need to be translated: One integer indicating if the person is male (0) or female (1) and one indicating if the person is an employee (1) or not (0).

    I tried this in my xml:
    <field name="employee" title="Is employee" type="checkbox" >
    <valueMap>
    <value id="1">true</value>
    <value id="0">false</value>
    </valueMap>
    </field>

    With this settings I can manipulate the employee field of the database, but strange is that it's always false when loading a record into my dynamic form.
    How to load the correct value when binding a record to my dynamic form?

    And as second question: How can I have two radio buttons to decide whether a person is female or male? How must the according xml definition of the field look like?
    (In previous tries I got some drop downs visible, but they never worked throwing an exception that 'true' is not an accepted value by the database although I wrote an id in the value map.)

    #2
    There is now a built-in solution for this which is the simplest - grab a nightly build (smartclient.com/builds) and look at DataSourceField.sqlStorageStrategy.

    The field should be declared of type "boolean". That and setting editorType="RadioGroupItem" will give you the radio buttons you want.

    Comment

    Working...
    X