Announcement

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

    setDataPath() with nested Data Sources

    I've got a ProgramDS with a nested PersonDS with the relevant field declarations as follows:

    PersonDS
    Code:
        DataSourceField field1 = new DataSourceTextField ("personId", "Person Id");
        field1.setRequired(true);
        field1.setPrimaryKey(true);
        DataSourceField field2 = new DataSourceTextField ("fullName", "Full Name");
        field2.setRequired (false);
    ProgramDS
    Code:
        DataSourceField managerField = new DataSourceTextField("manager", "Manager");
        managerField.setForeignKey(personDS.getID()+".personId");
        managerField.setEditorType(new ComboBoxItem());
        managerField.setTypeAsDataSource(personDS);
    I have successfully used setDisplayField() and setValueField() to have an editable form displaying the person's 'fullName' while the underlying value is the personId. Now I need to use the same DS with a DetailViewer and I want to display the fullName instead of the personId.

    I can't find the right argument for setDataPath() to do this (assuming that is the way to do it). My best guess was:
    Code:
        managerDVField = new DetailViewerField("manager", "Manager");
        managerDVField.setDataPath("manager/fullName");
    But this yields a blank entry. Leaving the DataPath null or setting it to "manager" yields the personId. Any tips?

    v8.2p_2012-04-25/EVAL

    #2
    You don't want to use dataPath for this (it's for something else).

    It's an omission in the API that detailViewer doesn't understand valueField/displayField, but you can get around it by just use the formatter APIs to return the value of the displayField.

    Comment


      #3
      I'm assuming you mean the DetailFormatter interface. But when I look at the record that gets passed into the format routine, there's no nested structure reflecting the nested PersonDS. The 'manager' attribute has a string value equal to the personId.

      Comment


        #4
        Right - a substructure won't be there unless you've loaded it, and generally the right approach is not to deliver the entire substructure but just needed field via a SQL join or it's equivalent (eg, dataSourceField.includeFrom).

        Comment

        Working...
        X