Announcement

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

    How to get display field value from Listgrid record

    Hi,
    I have a Listgrid attached to the RestDataSource with a foreign key field with valueField and displayField properties set.
    This makes displaying description text in place of id value for that key field nicely.
    I can get selected record and its values, but my question is:
    How to get displayed value (description, not underlaying id value) for that key field ?
    Thanks,
    MichalG
    ps sorry if this is trivial, but looks like I can't solve this easy way.

    #2
    If you're referencing another datasource using the foreign key, one of the ways to do it would be something along those lines:

    Code:
    treeGrid.addRowEditorExitHandler(new RowEditorExitHandler() {
                            @Override
                            public void onRowEditorExit(RowEditorExitEvent rowEditorExitEvent) {
                                RestDataSourceFactory.createForeignKeyDS().fetchData(
                                        new AdvancedCriteria("_id", OperatorId.EQUALS, rowEditorExitEvent.getRecord().getAttribute("foreignKeyId")),
                                        new DSCallback() {
                                            @Override
                                            public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
                                                // assume record is always there, add checks if necessary
                                                dsResponse.getData()[0].getAttribute("yourDescriptionProperty");
                                                // do whatever you want with the value
                                            }
                                        });
                            }
                        });
    regards,
    Andrius J.

    Comment


      #3
      Thanks for this.
      Fetching for each key value is an option, but I wonder if there is a simpler method considering the fact that I already can see display values in the grid. I would like just to get them along with other ListgridRecord data to feed a chart drawing, for example.
      MichalG

      Comment


        #4
        If anyone came across this:
        There is ListGrid.getCell(), which can be used via JSNI.
        It is discussed also here.
        HTH
        MichalG

        Comment

        Working...
        X