Announcement

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

    Not able to set value on Checkbox item in listgrid custom cell editor

    SmartClient Version: v11.0p_2016-08-22/LGPL Development Only (built 2016-08-22)
    All browsers

    I have a listgrid with a checkbox item as a custom cell editor. The cell's values are 1 or 0. So before I return the checkbox item i check what value the cell has and afterwards i want to set the value of the checkbox item accordingly. The thing is that the checkbox item does not change it's value and it is always checked as a default no matter what value i set it to. below is the code i tried to making it work.

    brightSchedGrid.setEditorCustomizer(new ListGridEditorCustomizer() {

    @Override
    public FormItem getEditor(ListGridEditorContext context) {
    switch (context.getRowNum()) {
    case 2:
    CheckboxItem cbi = new CheckboxItem();
    cbi.setShowLabel(false);
    GWT.log(brightSchedGrid.getRecord(2).getAttribute("value").toString());
    cbi.setValue(false);
    cbi.setDefaultValue(false);
    return cbi;
    }

    return null;
    }
    });


    If you want any further info please dont hesitate to ask

    #2
    Hi e.kousou,

    so logically the field is a boolean field, with 0 being false and 1 being true, correct?
    Why don't you include this in your .ds.xml field / Java DataSource DataSourceBooleanField definition?
    Code:
    type="boolean" [URL="http://www.smartclient.com/smartgwtee-latest/javadoc/com/smartgwt/client/docs/serverds/DataSourceField.html#sqlStorageStrategy"]sqlStorageStrategy[/URL]="singleChar10"
    IMHO you should not need the complicated Java code this way.

    Best regards
    Blama

    Comment


      #3
      well i populate this listgrid on the fly with no datasource, just cached data in the browser so creating a datasource etc. requires more code and complexity.
      I guess that if this is a bug it would be nice to have it fixed :)

      Comment


        #4
        Not a bug. The editor you return has it's value managed by the ListGrid as editing proceeds, so it's not going to work to just establish an initial value once when you return it.

        You can use a valueMap on the field to map between your 0 and 1 values and the true Boolean values that are normally expected for a type:"boolean" field.

        Comment

        Working...
        X