Announcement

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

    foreign key on GWTRPC datasource

    dear smartGWT community members,

    I'm following the GWT-RPC based datasource implementation thread and examples trying to evaluate usability of SmartGWT for my purposes.

    Currently I'm trying to create a grid that would display information composed of two model objects linked by foreign key reference and I'm lost.

    Probably I'm missing something very important about the whole concept..

    I have following code:

    EXAM DS:
    Code:
    DataSourceField patientFkField = new DataSourceSequenceField("patientFk");
    patientFkField.setForeignKey("patient.patientPk");
    with appropriate field in referenced datasource and some additional data field inherent to referenced PATIENT DS:
    Code:
    DataSourceSequenceField patientPkField = new DataSourceSequenceField("patientPk");
    patientPkField.setPrimaryKey(true);
    
    DataSourceTextField patientNameField = new DataSourceTextField("patientName");
    now I'd like to display a grid displaying list of EXAM objects but for each displaying also patient name.

    thus within the grid I add new field
    Code:
    ListGridField patientName = new ListGridField("patientName", "Patient Name");
    expecting that by some miracle the framework will fetch the collection inherent to the other datasource, find patient referenced by fk and display the name.

    obviously it fails, but to be honest I don't know how to proceed - e.g. where to study or find examples for this particular situation.

    what strikes me is, that in the GWTRPC thread examples the datasources are created based upon single model object (e.g. ExamBean..) - therefore if I'd like to keep my model facade logical and clean and work woth these concepts I'll inevitably run into this foreign key situation - surely I wouldn't want to define a new model object for every grid I want to display, but rather define up the object model according to the DB structure underneath!

    Is there any comment you'd find usable for me - e.g. how should I preceed or where should I look for inspiration?

    thank you very much, yours,
    -- peter
    Last edited by petrkalina; 9 Jun 2009, 08:41.

    #2
    is this issue similar?

    dear community members,

    in thread http://forums.smartclient.com/showthread.php?t=4304&highlight=setForeignKey there is an answer from the Isomorphic team stating that the tree widget that would allow for traversing the foreignKey declarations automaticly is under development.

    To me it seems that this is exactly what I'm looking for given that I'm not interested in tree, but in grid - does it mean that what I'm looking for is currently not achievable using the setForeignKey declaration and I'd either have to wait until future developments on "multi-datasource grid" or change my datasource declarations to match the displayed field set in the grid?

    Am I right? Accidental reader with any opinion please drop a note, because I'm in need of help here :-)

    sincerely, yours,
    -- peter

    Comment


      #3
      Hi Peter,

      Yes you're correct, for now, for a tree with mixed-type nodes, just declare a single DataSource that has just the fields that will actually be shown in the tree. You can, however, deliver data to the tree that has additional properties which are not shown, and then edit this additional data in other components. For example, when nodes are clicked on, you might allow editing of the node data in an adjacent form, and the form will use a different DataSource according to the node's type.

      Comment

      Working...
      X