Announcement

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

    Different DataSources for different Controls

    Hello,

    I have the following usecase:

    I want to show in a ListGrid a list of users, but in the ListGrid I only want to show 2 or 3 fields, like "name", "first name", and "birth date", for example.
    So I use the DataSource "users" for that purpose. That works fine.

    When I double click on one of the users, I open a DynamicForm, where A LOT of fields will be populated for this user. This includes joins, left joins, etc.

    This DynamicForm permits edits.

    My question is what would be a better approach:
    1) define a new DataSource "users_details" with the complex sql: left joins, joins, etc, for the DynamicForm.
    2) use the same DataSource "users" as for the ListGrid.

    If I understand correctly, each approach will have some problems:
    1) Since we have two different DataSources on the same table, if someone edits the name of the user in the DynamicForm, then the ListGrid will not be actualized, since they use different DataSources.
    And I need the ListGrid actualized if someone edits the name, of course.

    2) If I use the same DataSource for the ListGrid and for the DynamicForm, I won't have the problems of synchronization between the DynamicForm and the ListGrid I mentioned in 1) , but the complex query in the DataSource will be executed for populating the ListGrid, even if the ListGrid only need 2-3 fields from it and no complex query.
    And if I understand correctly, the data from the 100 fields defined in the complex DataSource will be transfered when populating the ListGrid, even if it doesn't use them all : it only uses three of them. (am I correct?? ).

    So what's the best approach for this? What would you recommend ?

    Using SmartGWT 3.0p EE.
    Last edited by edulid; 4 Jul 2012, 05:24.

    #2
    Both designs are valid..

    With a single DataSource, you can use different operationBindings so that the complex join is only used by certain components.

    With two different DataSources, you could use DataSource.updateCaches() to make sure the grid is updated by a form's save. See also dsRequest.addRelatedUpdates().

    Comment

    Working...
    X