Announcement

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

    Father-changes not propagated to child when using databound components.

    Hi Isomorphic

    could you please advise if the following behaviour is a bug, not supported, or an error on my behalf:

    I have two tables, father and child where:
    - father displaying all its values.
    - child displaying all its values and father.name instead of father.id (done with custom operationBinding including the SQL-join).

    When I update father.name within the app, this update is not shown on the child, although FK-relationship in the .ds.xml is set (and SmartGWT therefore should also propagate father-changes to all Widgets with FKs to the fatherDS, not only the Widgets with the fatherDS, as I'd suppose).

    Code:

    father.ds.xml
    Code:
    <!-- Auto-generated from database table T_COMPANY -->
    
    <DataSource 
    	schema="myschema"
    	dbName="Oracle"
    	tableName="T_COMPANY"
    	ID="T_COMPANY"
    	dataSourceVersion="1"
    	generatedBy="SC_SNAPSHOT-2011-12-05/EVAL Deployment 2011-12-05"
    	serverType="sql"
    >
    	<fields>
    		<field primaryKey="true" name="ID" type="sequence"></field>
    		<field name="NAME" title="Companyname" length="20" type="text" required="true"></field>
    	</fields>
    </DataSource>
    child.ds.xml
    Code:
    <!-- Auto-generated from database table T_UNIT -->
    
    <DataSource	schema="myschema"
    	dbName="Oracle"
    	tableName="T_UNIT"
    	ID="T_UNIT"
    	dataSourceVersion="1"
    	generatedBy="SC_SNAPSHOT-2011-12-05/EVAL Deployment 2011-12-05"
    	serverType="sql">
    	
    	<fields>
    		<field primaryKey="true" name="ID" type="sequence"></field>
    		<field name="COMPANY_ID" title="Companyname" foreignKey="T_COMPANY.ID" displayField="COMPANY" type="int" required="true"></field>
    		<field name="COMPANY" hidden="true" type="int" canSave="false" nativeName="NAME" tableName="T_COMPANY"></field>
    		<field name="NAME" title="Unitname" length="20" type="text" required="true"></field>
    	</fields>
    	<operationBindings>
    		<operationBinding operationType="fetch">
    			<tableClause>T_UNIT INNER JOIN T_COMPANY ON T_UNIT.COMPANY_ID = T_COMPANY.ID</tableClause>
    		</operationBinding>
    	</operationBindings>
    </DataSource>
    SQL Create statements (Oracle):
    Code:
    DROP TRIGGER T_UNIT_BI;
    DROP TRIGGER T_COMPANY_BI;
    DROP SEQUENCE T_UNIT_ID;
    DROP SEQUENCE T_COMPANY_ID;
    DROP TABLE T_COMPANY CASCADE CONSTRAINTS;
    DROP TABLE T_UNIT CASCADE CONSTRAINTS;
    
    CREATE TABLE T_COMPANY
    (
    ID INTEGER NOT NULL ,
    NAME VARCHAR2 (20) NOT NULL
    )
    ;
    
    ALTER TABLE T_COMPANY
    ADD CONSTRAINT PK_COMPANY PRIMARY KEY ( ID ) ;
    
    CREATE TABLE T_UNIT
    (
    ID INTEGER NOT NULL ,
    COMPANY_ID INTEGER NOT NULL ,
    NAME VARCHAR2 (20) NOT NULL
    )
    ;
    
    ALTER TABLE T_UNIT
    ADD CONSTRAINT PK_UNIT PRIMARY KEY ( ID ) ;
    
    
    ALTER TABLE T_UNIT
    ADD CONSTRAINT FK_T_UNIT_T_COMPANY FOREIGN KEY
    (
    COMPANY_ID
    )
    REFERENCES T_COMPANY
    (
    ID
    )
    ;
    
    CREATE SEQUENCE T_COMPANY_ID
    NOCACHE
    ORDER ;
    
    CREATE SEQUENCE T_UNIT_ID
    NOCACHE
    ORDER ;
    
    CREATE OR REPLACE TRIGGER T_UNIT_BI
    BEFORE INSERT ON T_UNIT
    FOR EACH ROW
    WHEN (NEW.ID IS NULL)
    BEGIN
    SELECT T_UNIT_ID.NEXTVAL INTO :NEW.ID FROM DUAL;
    END;
    /
    
    CREATE OR REPLACE TRIGGER T_COMPANY_BI
    BEFORE INSERT ON T_COMPANY
    FOR EACH ROW
    WHEN (NEW.ID IS NULL)
    BEGIN
    SELECT T_COMPANY_ID.NEXTVAL INTO :NEW.ID FROM DUAL;
    END;
    /
    
    INSERT INTO T_COMPANY (NAME) VALUES ('ACME');
    INSERT INTO T_COMPANY (NAME) VALUES ('Foocomp');
    INSERT INTO T_UNIT (COMPANY_ID, NAME) VALUES ('1', 'ACME_UNIT1');
    INSERT INTO T_UNIT (COMPANY_ID, NAME) VALUES ('2', 'foo UNIT1');
    INSERT INTO T_UNIT (COMPANY_ID, NAME) VALUES ('1', 'ACME_UNIT2');
    INSERT INTO T_UNIT (COMPANY_ID, NAME) VALUES ('2', 'foo UNIT2');
    COMMIT;
    Java (integrates in built-in-ds sample)
    Code:
    package com.smartgwt.sample.client;
    
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.layout.HLayout;
    import com.smartgwt.client.widgets.layout.VLayout;
    import com.google.gwt.core.client.EntryPoint;
    
    public class Testcase implements EntryPoint {
    
    	@Override
    	public void onModuleLoad() {
    
    		VLayout vL = new VLayout() {
    			{
    				setWidth100();
    				setHeight100();
    				final DataSource unitDS = DataSource.get("T_UNIT");
    				final DataSource companyDS = DataSource.get("T_COMPANY");
    
    				HLayout twiceFather = new HLayout() {
    					{
    
    						ListGrid companyLG1 = new ListGrid() {
    							{
    								setDataSource(companyDS);
    								fetchData();
    								setCanEdit(true);
    							}
    						};
    
    						ListGrid companyLG2 = new ListGrid() {
    							{
    								setDataSource(companyDS);
    								fetchData();
    								setCanEdit(true);
    							}
    						};
    						setMembersMargin(10);
    						addMember(companyLG1);
    						addMember(companyLG2);
    
    					}
    				};
    
    				ListGrid unitLG = new ListGrid() {
    					{
    						setDataSource(unitDS);
    						fetchData();
    						setCanEdit(true);
    					}
    				};
    
    				setMembersMargin(10);
    				addMember(twiceFather);
    				addMember(unitLG);
    			}
    		};
    		vL.draw();
    	}
    }
    I'm on 3.0 eval, FF10.0, GWT Development mode and production.

    Thank you,
    Blama

    #2
    No, joining to a field in a related DataSource does not make it automatically writable. Note that a simple join like this can now be achieved with a single property declaration (see DataSourceField.includeFrom).

    Comment


      #3
      Hi Isomorphic,

      thank you for the fast reply.

      I didn't know about "includeFrom", works like a charm.

      I did not talk about using the child-ListGrid to edit father's display value, what I wanted to say is if another ListGrid, directly bound to father, changes the display value used in child-ListGrid, this is NOT shown in the child-ListGrid.
      It doesn't matter there if it is an own "operationBinding.fetch" or "includeFrom" in the DS (see testcase)

      Is this expected behaviour or a bug or not correct setup on my side?

      Thank you,
      Blama

      Comment


        #4
        See operationBinding.cacheSyncOperation - you need to make sure that whatever operation is chosen as the cache sync operatiois returning the new display value.

        Comment

        Working...
        X