Announcement

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

  • ellisd5
    replied
    My new code isn't quite right, causes the editors to not open until the 2nd click.

    Also getting a weird issue with some of the edit fields showing the value of the attribute which is an ID number but id expect it to show the name as SelectItem should be displaying the display value for that ID. It's weird though, it's not all columns and once if expanded the editor they appear fine.

    Attached image, quite baffled by this behaviour, if anyone can shed some light I'm what I'm doing wrong would really appreciate it.

    Cheers,
    Dale
    Attached Files

    Leave a comment:


  • ellisd5
    replied
    Thanks again, had a little play with it and the below code seems to be working, not sure if it's the best way but it works so I'm happy!

    Code:
                inputGrid.setDataSource(new TaskFlowInputsDS());
                inputGrid.setAlwaysShowEditors(true);
    
                ListGridField name = new ListGridField(TaskFlowInputsDS.NAME);
                ListGridField type = new ListGridField(TaskFlowInputsDS.DATA_TYPE_DISPLAY);
    
                SelectItem fieldsSelect = new SelectItem();
                fieldsSelect.setOptionDataSource(fieldsDataSource);
                fieldsSelect.setValueField(TaskFlowFieldDS.ID);
                fieldsSelect.setDisplayField(TaskFlowFieldDS.NAME);
                fieldsSelect.setAllowEmptyValue(true);
                fieldsSelect.setEmptyDisplayValue("No Field Mapped");
                fieldsSelect.setAddUnknownValues(false);
    
                ListGridField inputField = new ListGridField(TaskFlowInputsDS.INPUT_FIELD_ID, "Mapped Field");
                inputField.setEditorProperties(fieldsSelect);
                inputField.setCanEdit(true);
                inputGrid.setEditorCustomizer(new ListGridEditorCustomizer() {
                    @Override
                    public FormItem getEditor(ListGridEditorContext listGridEditorContext) {
                        Integer dataTypeId = listGridEditorContext.getEditedRecord().getAttributeAsInt(TaskFlowInputsDS.DATA_TYPE_ID);
                        if (dataTypeId != null) {
                            Criteria criteria = new Criteria();
                            criteria.addCriteria(TaskFlowFieldDS.DATA_TYPE, dataTypeId);
                            listGridEditorContext.getDefaultProperties().setOptionCriteria(criteria);
                        }
                        return null;  //To change body of implemented methods use File | Settings | File Templates.
                    }
                });
    
                inputGrid.setFields(name, type, inputField);
    Thanks,
    Dale

    Leave a comment:


  • Blama
    replied
    Hi ellisd5,

    sorry, I didn't read closely enough.
    Perhaps ListGrid.setEditorCustomizer(ListGridEditorCustomizer customizer) is the correct approach, although I didn't try it, yet.

    Best regards,
    Blama

    Leave a comment:


  • ellisd5
    replied
    Thanks for the reply Blama,

    Not sure how that would work?, if I set the setOptionCriteria for the SelectItem then the criteria would be applied for every row in the ListGrid which would not be a dependant select.

    What I'm trying to achieve is a dependant select, so I need to set the Criteria based on the current rows "DATA_TYPE_ID" ListGridRecord attribute.

    Thanks,
    Dale

    Leave a comment:


  • Blama
    replied
    Hi ellisd5,

    please try SelectItem.setOptionCriteria(Criteria c).

    Best regards,
    Blama

    Leave a comment:


  • ellisd5
    started a topic Databound dependant select in ListGrid

    Databound dependant select in ListGrid

    Hi all,

    I am displaying a ListGrid, I have 3 piece of data that I'm displaying, "Name", "Data Type" and "Mapped Field".

    In this ListGrid the Mapped Field attribute is editable. The editor type is a select item that will retrieve some fields that can be mapped.

    I only want certain fields to be returned based on the data type. So basicly the selectItem values are dependant on the data type value.

    This is my code that doesn't currently work...
    Code:
                inputGrid.setDataSource(new TaskFlowInputsDS());
                inputGrid.setAlwaysShowEditors(true);
    
                ListGridField name = new ListGridField(TaskFlowInputsDS.NAME);
                ListGridField type = new ListGridField(TaskFlowInputsDS.DATA_TYPE_DISPLAY);
    
                SelectItem fieldsSelect = new SelectItem() {
                    @Override
                    protected Criteria getPickListFilterCriteria() {
                        Integer dataTypeId = 1; //TODO - Get value from TaskFlowInputsDS.DATA_TYPE_ID
                        Criteria criteria = new Criteria();
                        criteria.addCriteria(TaskFlowFieldDS.DATA_TYPE, dataTypeId);
                        return criteria;
                    }
                };
                fieldsSelect.setOptionDataSource(fieldsDataSource);
                fieldsSelect.setValueField(TaskFlowFieldDS.ID);
                fieldsSelect.setDisplayField(TaskFlowFieldDS.NAME);
                fieldsSelect.setAllowEmptyValue(true);
                fieldsSelect.setEmptyDisplayValue("No Field Mapped");
                fieldsSelect.setAddUnknownValues(false);
    
                ListGridField inputField = new ListGridField(TaskFlowInputsDS.INPUT_FIELD_ID, "Mapped Field");
                inputField.setEditorProperties(fieldsSelect);
                inputField.setCanEdit(true);
    
                inputGrid.setFields(name, type, inputField);
    The reason this code doesn't work is that overridden getPickListFilterCriteria() method is not getting called. I have used this approach in a DynamicForm and it works fine.

    The example in the showcase for a dependant select in a list grid is not data bound, it uses setEditorValueMapFunction which won't work for data bound SelectItem.

    So is it possible to achieve a data bound select in a list grid?

    Thanks,
    Dale

    SmartGWT Version : 4.0p
    SmartGWT Build Date : Mon Dec 23 10:04:00 GMT 2013
    GWT Version : 2.4.0
    Last edited by ellisd5; 31 Jan 2014, 03:47.
Working...
X