Announcement

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

    Inline Editing issue in listgrid

    smartgwt version 12
    browser : chrome

    I have a listgrid which has inline editing capability. I added 3 combobox item for three fields (A, B,C). I am trying to achieve dynamic datasource setting for those three combobox item based on the other field (D).

    I have added sample code ::

    ListGrid listgrid = new ListGrid();
    listgrid.setDataSource("data");
    listgrid.setAutoFetchData(true);

    ListGridField A = new ListGridField("a", "A");
    ComboBoxItem aItem = new ComboBoxItem("a", "A");
    aItem.setOptionDataSource("emptyDS");
    aItem.setAutoFetchData(true);
    aItem.setValueField("key");
    aItem.setDisplayField("value");
    A.setEditorProerties(aItem);

    ListGridField B = new ListGridField("b", "B");
    ComboBoxItem bItem = new ComboBoxItem("b", "B");
    bItem.setOptionDataSource("emptyDS");
    bItem.setAutoFetchData(true);
    bItem.setValueField("key");
    bItem.setDisplayField("value");
    B.setEditorProerties(bItem);

    ListGridField C = new ListGridField("c", "C");
    ComboBoxItem cItem = new ComboBoxItem("c", "C");
    cItem.setOptionDataSource("emptyDS");
    cItem.setAutoFetchData(true);
    cItem.setValueField("key");
    cItem.setDisplayField("value");
    C.setEditorProerties(cItem);

    ListGridField D = new ListGridField("d", "D");

    listgrid.setFields(A, B, C, D);

    I am setting DataSources to those comboBox items when user double click the record.

    listgrid.addRecordDoubleClickHandler(new RecordDoubleClickHandler() {
    public void onRecordDoubleClick(RecordDoubleClickEvent event) {
    datasource.getInstanc().validateData(event.getRecord(), new DSCallback() {
    public void execute(DSResponce response, Object o, DSRequest request ) {
    aItem.setOptionDataSource(response.getData[0].getAttribute("a"));
    bItem.setOptionDataSource(response.getData[0].getAttribute("b"));
    cItem.setOptionDataSource(response.getData[0].getAttribute("c"));
    }
    });
    }
    });

    But the problem is all three combobox is getting same datasource. eventhough i set different datasource.
    What I m doing wrong here ??

    #2
    You can’t change the fields after they have been passed to setFields() (per docs). Don’t do the setFields() call, or perhaps don’t even construct the ListGrid at all, until you have the optionDataSource names.

    Comment


      #3
      Hi,

      I call setFields() at last after setting optionDataSource. But its not working. Every record is gonna have different datasources for A,B,C and I m setting the datasources in record Double click handler. Is it achievable in smartgwt ?/

      Comment


        #4
        This interaction is achievable in multiple ways, but you do have to follow the docs. If you want to change the optionDataSources for every record, you'd need to call setFields() each time you start editing a new record. Since setFields() also cancels the current editing, you'd have to re-initiate editing using startEditing().

        But this is likely not what you want to do - we would guess that all optionDataSources for each column return records with the same set of fields. If so, instead of having a different DataSource per row, just have a single optionDataSource per column and pass criteria to indicate what set of records should be returned.

        Comment


          #5
          I fixed this issue setting single OptionDataSource to column and return necessary set of records from server side.

          Thank you.

          Comment

          Working...
          X