Announcement

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

  • zaj
    replied
    Thanks a lot!!

    Leave a comment:


  • Blama
    replied
    If it is not working, please how the java definition of ListGrid + ListGridFields and also .ds.xml files if they changed since post #12.

    Leave a comment:


  • Blama
    replied
    If you are happy with the change after leaving the row, this should be possible and working without your ChangeHandler as well in your application.

    Please note that in the sample, the country-code does NOT change if you STAY in the row, e.g. switch to the 1st field of the currently edited row after selecting a new entry in the dropdown.

    Best regards
    Blama

    Leave a comment:


  • zaj
    replied
    Yes,that is what i meant

    Leave a comment:


  • Blama
    replied
    What does "frame" mean? Does it mean "anywhere outside the row currently being edited"?

    Leave a comment:


  • zaj
    replied
    Hi Blama,

    anywere in the frame will make the code to change. for e.g. I select Latvia it updates the code column to LV or if I select Estonia it show the code EE.

    Leave a comment:


  • Blama
    replied
    Sorry, still not seeing it. Where exactly do you click in the sample after selecting a different entry from the dropdown?

    Leave a comment:


  • zaj
    replied
    >>But only if you leave the row. Not if you change to e.g. the 1st column city.

    yes if you change the city col nothing happens BUT when you change the country name from the Country col its corresponding Country code is displayed and that is also what i was trying to do. that is, when i select the production line from the combo box, i wanted its corresponding batch line to show. but it was not working for me using purely datasource file as shown in the showcase. But it worked for me using the change handler. That is why i was eager as to what i was doing i was missing even though i tried to resemble the showcase code.

    Leave a comment:


  • Blama
    replied
    But only if you leave the row. Not if you change to e.g. the 1st column city.

    At least this is happening for me in GC42, FF26, IE11 in the showcase sample.

    Leave a comment:


  • zaj
    replied
    Hi Blama,

    Yes it is working for me. I am usjng chrome to view the showcase. For e.g when you change the country from the country column ehich is a Combo box its corresponding country code changes automatically.

    Leave a comment:


  • Blama
    replied
    Originally posted by zaj View Post
    But I was aalso expecting that to work in my case,but did not
    I don't understand. Are you saying it is working in the example? Because it is not for me.

    Leave a comment:


  • zaj
    replied
    cheers mate!!
    -- but only after leaving the row
    But I was aalso expecting that to work in my case,but did not
    Last edited by zaj; 26 May 2015, 00:21.

    Leave a comment:


  • Blama
    replied
    FYI: The sample you mentioned in the code does also NOT show the data after just selecting an entry, but only after leaving the row and therefore triggering the cacheSync-SELECT statement of the changed row. The difference to your setup is only that the includeFrom-field is defined in Java rather than in the .ds.xml.

    Leave a comment:


  • Blama
    replied
    Hi zaj,

    this is the "change handler"-way I mentioned in my last post. Using that you should also be able get rid of the fetch by having the bize-value as PickList-ListGridField in the ComboBoxItem and accessing it in the changed-handler via ((ComboBoxItem)event.getItem()).... (as enhancement). See ComboBoxItem.setPickListFields() for details on how to make the information available in the ComboBoxItem.

    The other way I described (one field with: linename (bize)) involves a similar setup for the ComboBoxItem (two ListGridFields, one hidden, one with a setCellFormatter() creating the linename (bize)) for the edit-part.
    The display-part is .ds.xml-only with a customSelectExpression (mentioned previously, two hidden="true"-includeFrom fields, another field with customSelectExpression used as displayField for prfk. You might want to set relatedTableAlias on the prfk-field in order to be sure that your customSelectExpression will always work).

    I'm pretty sure a .ds.xml-only solution is NOT possible because by default the new row data after ADD/UPDATE comes from the cacheSync and is therefore not available until the row is successfully saved.

    Best regards
    Blama
    Last edited by Blama; 26 May 2015, 00:10.

    Leave a comment:


  • zaj
    replied
    Hi Blama,

    Appreciate your helpful feedbacks.
    I was able to achieve the requirement using the change handlers in my java class(I have provided the code for anyone to refer). But i am very eager and still wondering how could I have achieved this purely using datasource file only.
    I also added the join and required to my foreign key field but still no luck!!Below is my datasource file and the Query which smartgwt generates. Can you please help me to achieve this.I will appreciate it.
    Code:
     
    <DataSource ID="productionlinedetailDS" serverType="sql" tableName="proined">
    	<fields>
    		<field name="id" type="sequence" hidden="true" primaryKey="true" />		
    		<field name="prfk" title="Production Line" type="integer" foreignKey="productionlineDS.id" joinType="outer" displayField="productionlineName" required="true" editorType="ComboBoxItem"  />
    		<field name="productionlineName" includeFrom="productionlineDS.name" hidden="true" />
    		<field name="productionlineBize" includeFrom="productionlineDS.bize"/>
    		
    		<field name="pu" title="Unit" type="text" length="5">
    		<valueMap>
                    <value>Kg</value>
                    <value>Liter</value>
                    <value>Pcs</value>
                    <value>Other</value>
                </valueMap>
            </field>
    		 <field name="up" title="Single Unit Package / Batch" type="integer"/>
    		 <field name="ups" title="Multiple Unit Package / Batch" type="integer"/>
    		 <field name="amc" title="Multiple Unit Package Content" type="integer"/>
            <field name="was" title="Production Staff" type="integer"/>
    	</fields>
    </DataSource>
    Code:
    SELECT
        *
    FROM
        (
            SELECT
                *,
                ROW_NUMBER() OVER (ORDER BY id) AS rowID
            FROM
                (
                    SELECT
                        TOP 100 PERCENT proined.id,
                        proined.prfk,
                        proined.pu,
                        proined.up,
                        proined.ups,
                        proined.amc,
                        proined.was,
                        proine.name AS productionlineName,
                        proine.bize AS productionlineBize
                    FROM
                        proined
                    LEFT OUTER JOIN
                        proine
                    ON
                        proined.prfk = proine.id
                    WHERE
                        (
                            '1'='1')) x) y
    WHERE
        y.rowID BETWEEN 1 AND 75
    SELECT
        COUNT(*)
    FROM
        proined
    LEFT OUTER JOIN
        proine
    ON
        proined.prfk = proine.id
    
    
    What I am trying to do is very similar to this showcase example where I select the Country from the Combo box and the corresponding code is apdated in the Code Coulumn.
    http://www.smartclient.com/smartgwtee/showcase/#sqlIncludeFromDynamic.

    Just to give you and others an idea how i managed to achieve this using handler is below

    Code:
    if (prfk != null)
    		{
    			prfk.addChangedHandler(new ChangedHandler()
    			{
    				@Override
    				public void onChanged(ChangedEvent event)
    				{
    					final int rowNum = event.getRowNum();
    					if (event.getValue() != null)
    					{
    						updateData(prfkDS, new Criteria("id", event.getValue().toString()), rowNum);
    					}
    				}
    			});
    		}
    
    private void updateData(DataSource ds, Criteria criteria, final int rowNum)
    	{
    		ds.fetchData(criteria, new DSCallback()
    		{
    			@Override
    			public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest)
    			{
    				Record[] recdata = dsResponse.getData();
    				if (recdata != null && recdata.length > 0)
    				{
    					
    					listgrid.setEditValue(rowNum, "bize", recdata[0].getAttribute("bize"));
    					listgrid.refreshRow(rowNum);
    				}
    				else
    				{
    					
    				}
    			}
    		});
    	}

    Leave a comment:

Working...
X