Announcement

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

    Related DataSource update

    Be sure your post includes:

    1. SmartGWT 2.3 Power


    Please let us know how to implement the following:

    Table Company

    Company Name, Company Address ID (Number)

    Address

    Address ID, City, State

    Data Source for Address is Address and Company is Company.


    In a List Grid I an displaying all company names and city state where the company belongs.

    When I update a particular Addess in separate Form:

    for example state or city for a Address, I am expecting the Comapny city or state in the List Grid also should be reflect the current or updated one. But I am still seeing the old data untill I close the application.

    Let me know how to get the data reflected/updated when one datasource is updated.

    #2
    What kind of DataSource?

    Can you post the DataSource definitions (all three)?

    Comment


      #3
      Company DataSource:

      <DataSource
      dbName="Oracle"
      tableName="T_COMPANY"
      ID="T_COMPANY"
      serverType="sql"
      >
      <field name="CY_NAME" title="Company Name" length="100" type="text" hidden="false" required="true"></field>
      <field name="ADDR_CITY" title="City" length="20" type="text" hidden="false" customSQL="true" tableName="T_ADDRESS"></field>
      <field name="ADDR_COUNTRY_ID" title="Country" length="10" type="number" hidden="true" customSQL="true" tableName="T_ADDRESS"></field>
      <field name="CN_NAME" title="Country" length="75" type="text" customSQL="true" tableName="T_ADDR_COUNTRY_MASTER"/>
      <field name="ADDR_STATE_ID" title="State" length="10" type="number" hidden="true" customSQL="true" tableName="T_ADDRESS"></field>
      <field name="ST_NAME" title="Country" length="75" type="text" customSQL="true" tableName="T_ADDR_STATE_MASTER"/>
      <field name="ADDR_LN_1" title="Addr Line1" length="75" type="text" customSQL="true" tableName="T_ADDRESS"></field>
      <field name="ADDR_ZIP_CODE" title="Zip Code" length="10" type="text" customSQL="true" tableName="T_ADDRESS"></field>

      Operation Binding goes here !....

      </DataSource>


      Address Datasource

      <DataSource
      dbName="Oracle"
      tableName="T_ADDRESS"
      ID="T_ADDRESS"
      serverType="sql"
      >

      <fields>
      <field primaryKey="true" name="ADDR_ID" type="sequence" hidden="true"/>
      <field name="PTY_CONT_ID" title="Party ID" type="text" hidden="true" customSQL="true" tableName="T_PTYCONTADDR_LINK"/>
      <field name="USR_TYPE" title="USR Type" type="text" hidden="true" customSQL="true" tableName="T_PTYCONTADDR_LINK"/>
      <field name="ADDR_NAME" title="Location" length="50" type="text" />
      <field name="ADDR_TYP" title="Typed" length="50" type="text" hidden="true" />
      <field name="ADDR_TYPE_VALUES" title="Type" length="50" type="text" customSQL="true" hidden="false" tableName="V_ADDR_TYPE_MASTER"/>
      <field name="ADDR_LN_1" title="Address 1" length="75" type="text" hidden="false" />
      <field name="ADDR_LN_2" title="Address 2" length="75" type="text" hidden="false" />
      <field name="ADDR_LN_3" title="Address 3" length="75" type="text" hidden="false" />
      <field name="ADDR_CITY" title="City" length="75" type="text" />
      <field name="ADDR_STATE_ID" type="number"></field>
      <field name="ST_NAME" title="State" length="75" type="text" customSQL="true" tableName="T_ADDR_STATE_MASTER"/>
      <field name="ADDR_COUNTRY_ID" type="number"></field>
      <field name="CN_NAME" title="Country" length="75" type="text" customSQL="true" tableName="T_ADDR_COUNTRY_MASTER"/>
      <field name="ADDR_ZIP_CODE" title="ZIP Code" length="75" type="text" />
      </fields>
      </DataSource>

      Comment


        #4
        OK, seems like you didn't include the operationbindings, but those are key to answering your question.

        Comment


          #5
          <OperationBindings>
          <OperationBinding OperationType="fetch"
          customValueFields = " City, state..."
          customCriteriaFields = " City, State,..."
          <tableClause>T_COMPANY, T_ADDRESS</tableClause>
          <whereClause>
          T_COMPANY.MAIN_ADDR_ID = T_ADDRESS.ADDR_ID and ($defaultWhereClause)
          </whereClause>

          >

          The above goes in Company Datasource. There is no Operation Binding for Address

          </OperationBinding>
          </OperationBindings>

          Comment


            #6
            OK, if that was the real operationBinding, it wouldn't work (incorrect capitalization). Please don't modify code before posting, the details matter. In this case, if an operationBinding does not have an operationId, it will be used as the cacheSync operation, so if it specifies a join, it will automatically pull back the correct fields. Most likely, even though you removed it before posting, you have an operationId specified. Just remove it, client and server side.

            Comment


              #7
              My Datasource is huge file and I cannot post the whole DS.

              Please dont lookin to syntax etc.

              I do not have any id specificed for the Operation.

              My Question is How do I able to get a Datasource (in the above example Party) gets updated when I update an another datasource (Address).
              Probably please give a sample for writing the COmpany datasource.

              Let me provide you the scenario:

              Comapny A City is Sunnyvale and State is CA
              Company B City is Trenton and State is NJ

              If I go to address form and change the Address for Comapany A(city to Losangels) I should able to see it in listgrid that displays Company A along with city and State.

              Right now I an see the old data (old city ). I have to close the application and open to see the changes.
              Last edited by krishnafse2009; 28 Sep 2010, 16:06.

              Comment


                #8
                If you are updating the Address by way of the Company DataSource, it's automatic. Otherwise, if you for example have a grid showing companies, call invalidateCache() on it to cause new data to be fetched.

                Comment


                  #9
                  Note: a second approach is also available - if you can locate the individual Company record whose Address has just changed, you could call DataSource.updateCaches() with a DSResponse showing a successful update to the Company DataSource where just the fields derived from the Address DataSource have been changed. This will update all components that have stale Company records and avoids an additional fetch.

                  Comment

                  Working...
                  X