Announcement

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

    SelectItem Inside a ListGrid get value when getSelectedRecords is called

    I have searched far and wide but have yet to see someone use widgets and then get the value of a widget with getSelectedRecords()

    The goal of this solution is to have and end user check a few checkboxes and in the same row of the item that was checkboxed they should have selected a value for the state.

    Currently I have a list grid with 4 rows:
    Checkbox, 2 string text rows, DyanmicFrom(SelectItem)

    How I am creating the SelectItem to get inside of the ListGrid:


    theGrid= new ListGrid()
    {

    @Override
    protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum)
    {


    String fieldName = this.getFieldName(colNum);
    if (fieldName.equals("stateDropDown"))
    {
    DynamicForm rtrnForm = new DynamicForm();
    SelectItem state= new SelectItem();
    state.setShowTitle(false);
    state.setHeight(25);
    state.setWidth(175);
    state.setDefaultToFirstOption(true);
    rtrnForm.setFields(state);
    loadFunctionStates(state);
    return rtrnForm;
    }
    else
    {
    return null;
    }
    }
    }; ;
    }
    theGrid.setSelectionType(SelectionStyle.SIMPLE);
    theGrid.setSelectionAppearance(SelectionAppearance.CHECKBOX);
    theGrid.setShowRecordComponents(true);
    theGrid.setShowRecordComponentsByCell(true);


    Further down in the code we are then trying to get the record so that we can send the values else where in the system.

    for (ListGridRecord record : theGrid.getSelectedRecords())
    {
    int index = 0;
    for (String key : record.getAttributes())
    {
    // this is the column of the dynamicForm(SelectItem) objects that I need to get the value for the SelectItem
    if (index == 5)
    {
    SC.logDebug(key + " : " + record.getAttribute(key));

    SC.logDebug(key + " : " + record.getAttributeAsObject(key));
    DynamicForm df = (DynamicForm) record.getAttributeAsObject(key);
    }
    else
    {
    SC.logDebug(key + " : " + record.getAttribute(key));
    }

    index++;

    }
    }


    the problem is I can't get the SelectItem's value by using the Checkbox solution.. Does anyone have any other ideas?


    #2
    Why are you using recordComponents here instead of using normal ListGrid editing? There's no apparent reason why you would do this.

    If you do have some reason to use recordComponents, at the moment, you don't seem to have any code that would cause the recordComponent to store anything on the record. So your recordComponent is just sitting there managing a value, totally disconnected from your data model.

    Finally, it seems like you might be trying to access the active recordComponent starting from the record. To do this you would just use the call getRecordComponent(). recordComponents are not stored as accessible attributes on Records, so any attempt to iterate through Record attributes to find a recordComponent is doomed to fail.

    Comment

    Working...
    X