Announcement

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

    ListGridField and setOptionDataSource

    Hi all,

    *fingers crossed theres an answer this time!*

    I have a ListGrid that loads up to several hundred records at a time. Some of the ListGridFields are also derived from other datasources.

    These records are Memberships, which has a corresponding Member. The ListGrid is tied to MembershipDS, and each record in the ListGrid displays the Membership information, as well as fields from the related Member.

    Now I have read through the doc on setOptionDataSource for ListGridField, and its suggested approach of sending the actual display value along with the ID (so not the entire valueMap is loaded). But I'm only dealing with several hundred records at a time, and I would like to first try the datasource-based approach.

    The field definition for the grid below works brilliantly! The Member's firstname is retrieved and displayed correctly.
    Code:
    // firstname comes from MemberDS
    ListGridField firstnameField = new ListGridField("memberDSid", "Firstname");
    firstnameField.setOptionDataSource(MemberDS.getInstance());
    firstnameField.setValueField("id");
    firstnameField.setDisplayField("firstname");
    firstnameField.setAutoFetchDisplayMap(true);
    However, if I have a second field:
    Code:
    ListGridField surnameField = new ListGridField("memberDSid", "Surname");
    surnameField.setOptionDataSource(MemberDS.getInstance());
    surnameField.setValueField("id");
    surnameField.setDisplayField("surname");
    surnameField.setAutoFetchDisplayMap(true);
    Problems arise - the two fields use the same name of "memberDSid". The end result here is that the surname shows up in the Firstname column, and the record ID shows up in the Surname column.

    What is the recommended approach in this case? Is there a better way than sending the "memberDSid" with different names multiple times? (eg, "memberDSid4Firstname", "memberDSid4Surname", etc)


    For reference, my MembershipDS:
    Code:
    /**
     * Define datasource here
     */
    public MembershipDS(String id) {
      
      setID(id);
    
      // member, this is not shown, as the grid uses this to load the member details
      DataSourceIntegerField memberIDField = new DataSourceIntegerField("memberDSid");
      memberIDField.setForeignKey("memberDS.id");
      memberIDField.setHidden(true);
    
      // other Membership specific fields here
      ...
    }

    #2
    The same problem, did you find the solution?

    Comment

    Working...
    X