Announcement

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

    Setting CheckboxItems from non-boolean data

    Using SmartGWT Pro, how should I code the following? Thanks.


    1. A CheckboxItem that should be checked if database field "type" has a value of "CBN" otherwise unchecked. If user ticks the checkbox then I need to set "type" to "CBN" otherwise "PBN".
    One way would be to use a ValueMap, is this the correct approach?

    2. A set of CheckboxItems, say A to E, whose values all come from the same char(5) database field which contains Y or N corresponding to each CheckboxItem e.g. YYNNY means A, B and E should be checked and C and D should be unchecked. If the user checks or unchecks I need the database field to be updated.

    #2
    Remember to mention environment details such as what version of SmartGWT and what DataSource type you're using. We'll assume best practices (SQLDataSource).

    Both of these could be solved in SQL using Power Edition's SQL Templating features, specifically, the ability to map a DataSourceField to an arbitrary set of SQL expressions via field.customSelectExpression et al (see QuickStart Guide). In particular your #2 is very close to the bitwise and sample provided in the JavaDoc for field.customCriteriaExpression.

    In the absence of Power Edition, you can write DMI logic that transforms the data in the default DSResponse (again see QuickStart). This is slower and less declarative of course.

    Comment

    Working...
    X