Announcement

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

    Question regarding setOptionDatasource for 1:N Dropdown assignment in ListGrids

    Hi Isomorphic,

    I have a working setup for a ListGrid with 1:N Dropdown assignment of values.
    I've been trying that for one long time, so if you could add a simple example to the showcase, I'm sure many users would appreciate it.

    ds.xml excerpt:
    Code:
     
    	<fields>
    		<field primaryKey="true" hidden="true" name="ID" type="sequence"></field>
    		<field name="ANREDE_ID" title="Anrede" type="int" displayField="ANREDE" required="true"></field>
    		<field name="ANREDE" hidden="true" nativeName="NAME" type="text" tableName="T_ANREDE"></field>
    ....
    	</fields>
    	<operationBindings>
    		<operationBinding operationType="fetch">
    			<tableClause>T_PERSON INNER JOIN T_ANREDE ON T_PERSON.ANREDE_ID = T_ANREDE.ID
    			</tableClause>
    		</operationBinding>
    	</operationBindings>

    .java excerpt:
    Code:
     
    		//Field to work with
    		ListGridField anredeIdLGF = boundList.getField("ANREDE_ID");
    
    		//DS for translating IDs to Strings
    		DataSource anredeDS = DataSource.get("T_ANREDE");
    		anredeDS.setCacheAllData(true);
    		
    		//Formitem when in "edit" in the ListGrid after doubleclick
    		//ComboBox so that the user can type. SelectItem would also be possible for short lists
    		ComboBoxItem anredeIdCBI = new ComboBoxItem();
    		anredeIdCBI.setOptionDataSource(anredeDS);
    		//"Translation"
    		anredeIdCBI.setValueField("ID");
    		anredeIdCBI.setDisplayField("NAME");
    		anredeIdLGF.setEditorType(anredeIdCBI);
    		
    		//SelectItem as filter, so that the top entry is empty in order to reset the filter.
    		//If .setEditorType used SelectItem, too, no new object would be needed.
    		SelectItem anredeIdSI = new SelectItem();
    		anredeIdSI.setOptionDataSource(anredeDS);
    		anredeIdSI.setValueField("ID");
    		anredeIdSI.setDisplayField("NAME");
    		anredeIdLGF.setFilterEditorType(anredeIdSI);
    		
    		//Enable filter
    		boundList.setShowFilterEditor(true);
    Now my question:
    In the Quick Start Guide (p. 65) you strongly suggest to push as much settings as possible to the .ds.xml file, which I like and do.
    Is there a possibility (or is it planned) to move the above Java code to the ds.xml file? http://www.smartclient.com/smartgwte...urceField.html does not list these options.

    Thank you,
    Blama

    #2
    Please clarify what you mean about 1:N assignment of values.

    There are plans to allow server-side business logic such as short bits of DMI logic to be embedded directly in .ds.xml files - see blog. If you want to make your UI more declarative, use Component XML (see docs).

    Comment


      #3
      Hi Isomorphic,

      you mean Server Script Blocks under http://blog.isomorphic.com/smart-gwt...ature-roadmap/ , don't you?
      It looks like that could solve my case.
      Do you also plan to extend the list of allowed *.ds.xml attributes (especially field-level)?
      In http://forums.smartclient.com/showthread.php?t=18093 you wrote that the format is extensible. I added a new question there.

      Regarding Component XML: I'll definitely look into that!

      Regarding "1:N assignment of values": I have two tables in relational DB:
      person(id: int, honorific_id: int, givenname: varchar, name: varchar)
      honorific(id: int, shortdesc: varchar, longdesc: varchar), DB-level FK is set.

      Now when displaying, editing and filtering "person" in a ListGrid I of course want to see the possible honorific-entries as textual Dropdown. That is what I meant by "1:N assignment of values". I rolled this question out to http://forums.smartclient.com/showthread.php?t=20786

      From my POV this thread is closed and possible answers are most likely placed better in
      http://forums.smartclient.com/showthread.php?t=20786
      http://forums.smartclient.com/showthread.php?t=18093

      Thank you, your answers are really helpful!
      Blama
      Last edited by Blama; 6 Feb 2012, 01:13.

      Comment

      Working...
      X