Announcement

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

    ComboBoxItem.getSelectedRecord() fails in derived class, when used within a ListGrid

    I have a custom-build form item. It is a combobox that presents a dropdown list with several columns. The class is derived from the smartGWT ComboBoxItem (class CustomComboBoxItem extends ComboBoxItem).

    The CustomComboBoxItem works fine in a form.

    There is a problem when using the CustomComboBoxItem in the row editor of a ListGrid.
    The method ComboBoxItem.getSelectedRecord() always fails with the following exception:
    Exception caught: (TypeError) @com.smartgwt.client.widgets.form.fields.ComboBoxItem::getSelectedRecord()([]): Object doesn't support property or method 'getSelectedRecord'
    I have attached the full stack trace.

    I created a minimal test code to reproduce the issue. It is derived from the BuildInDS sample code. Just add/replace the files attached below.
    In order to trigger the exception: edit a row in the ListGrid, open the dropdown for the "Item" column and click on an item in the dropdown list.

    I'm using SmartGWT Framework (SNAPSHOT_v9.1d_2013-12-03/PowerEdition). The issue is reproducible in IE9 and FF16.
    I suspect that could be a bug in SmartGWT?
    Attached Files

    #2
    You can resolve this by looking at event.getItem() rather than calling getSelectedRecord() on this:
    Code:
        selected = new ComboBoxItem(event.getItem().getJsObj()).getSelectedRecord();
    The problem is that your Java form item is acting as a kind of template for the items created by the ListGrid, and is not associated with the live item in Javascript scope.
    This doesn't apply to form items where you create an explicit item which is actually displayed on the page.

    Regards
    Isomorphic Software
    Last edited by Isomorphic; 16 Dec 2013, 15:08.

    Comment

    Working...
    X