Announcement

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

    Advise on Multiple Components using single Data Source

    Hi,

    Using SGWT 2.5

    I have a use case where on a page i have a form and a grid. Rather than having multiple data sources for each of these, i have created a single DS and applied to both these widgets. So that i can get the entire page data in one go.

    i see 2 issues here,

    1. Response construction - I created a response which conforms to the DS standard, i.e.
    Code:
    <response>
      <status>0</status>
      <startRow>0</startRow>
      <endRow>2</endRow>
      <totalRows>2</totalRows>
      <data>    
        <record>
             <field1></field1>
             <field2></field2>
        </record>
        <record>
             <field1></field1>
             <field2></field2>
        </record>
      </data>
    </response>
    In the above response format i wanted to include the form data as well. I tried adding it at same level as <data> within a <metadata> tag. In the datasource i used "field.setValueXPath" to identify the location. This helped me get the data in the form but it did not load the grid. So i put the <metadata> tag inside the 1st <record> element and both the form and grid got loaded with data.

    However i am not so sure about the XML format i created(i.e. does not look right, feels more of a work around). Any better solutions around creating a format that will help load both the form and grid via a single DS.

    2. Secondly both Form and Grid make separate server calls, which is just redundant. Can i make a single server call and yet have both the widgets loaded via DS.
    I have set the following 2 properties for both form and grid,
    Code:
    .setDataSource(ds);
    .setAutoFetchData(true);
    Any solutions around getting this done more efficiently.

    #2
    I'm not sure I understand the motivation for all this, but it sounds to me like this is a job for queuing

    Comment


      #3
      I'm having the similar requirement. I want to share the datasource with form and grid. Any good idea?
      The response is like below:
      Code:
      <response>
        <status>0</status>
        <startRow>0</startRow>
        <endRow>2</endRow>
        <totalRows>2</totalRows>
        <data>   
          <list>
          <record>
               <field1></field1>
               <field2></field2>
          </record>
          <record>
               <field1></field1>
               <field2></field2>
          </record>
          </list>
          <form_field1></form_field1>
          <form_field2></form_field2>
        </data>
      </response>

      Comment


        #4
        Not sure why you are creating own DS responses but the example you are talking about is in the showcase. Look for something called Master Details. It is exactly the scenario you are wanting to do (form and grid).

        This is what data sources were meant for - the same data being propagated to different widgets. You could have several widgets bound to same datasource.

        Comment

        Working...
        X