Announcement

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

    Adding Root Nodes to an XML-based DataSource

    Hi,

    I'm loading a DataBase from XML and want to add nodes later on. As long as such a Node is added as a child node to an existing node that works perfectly. However, if the Node should be a separate root node it does not appear.

    A TreeGrid is used to display the DS.

    There's no error or warning message I could provide...

    Can anyone give me some help please?

    Here's the DS:
    Code:
    	class CatStructureDS extends DataSource {
    
    		public static final String ID = "ID";
    		public static final String NAME = "Name";
    		public static final String LINK = "Link";
    		public static final String PARENT = "Parent";
    		
    		public CatStructureDS(String pId) {
    
    			setID(pId);
    			setRecordXPath("/Catalogs/Catalog");
    			
    			DataSourceTextField tIDField = new DataSourceTextField(ID, ID, 128);
    			tIDField.setPrimaryKey(true);
    			tIDField.setRequired(true);
    			
    			DataSourceTextField tNameField = new DataSourceTextField(NAME, NAME, 128);
    			tNameField.setRequired(true);
    			
    			DataSourceTextField tLinkField = new DataSourceTextField(LINK, LINK, 128);
    			
    			DataSourceTextField tParentField = new DataSourceTextField(PARENT, PARENT, 128);
    			tParentField.setForeignKey(pId+"."+ID); 
    
    			setFields(tIDField, tNameField, tLinkField, tParentField);
    
    			setClientOnly(true);
    		}
    	}
    and here the Add code that is called in the DS callback of the DS fetch operation:
    Code:
    					Record tRecord = new Record();
    					tRecord.setAttribute(getCatalogServer().getCatAttribute(Server.CatAttribute.ID), "::search");
    					tRecord.setAttribute(getCatalogServer().getCatAttribute(Server.CatAttribute.LABEL), X4App.i18n(X4App.APP, "Search"));
    					tRecord.setAttribute(getCatalogServer().getCatAttribute(Server.CatAttribute.PARENT), (String)null);
    					pDS.addData(tRecord);
    					
    					tRecord = new Record();
    					tRecord.setAttribute(getCatalogServer().getCatAttribute(Server.CatAttribute.ID), "::bookmarks");
    					tRecord.setAttribute(getCatalogServer().getCatAttribute(Server.CatAttribute.LABEL), X4App.i18n(X4App.APP, "Bookmarks"));
    					tRecord.setAttribute(getCatalogServer().getCatAttribute(Server.CatAttribute.PARENT), (String)null);
    					pDS.addData(tRecord);
    Ekki

    * GWT Rocks! * SmartGWT Rocks Even Harder! * SmartGWT PRO 2.0,
    GWT 2.0, Jetty 7.0.0, Eclipse 3.5.1, JRE 1.6.0_16 *
    For Evaluation only: MySQL 5.1.41, Connector/J 5.1.10

    CI-CUBE.BIZ feat. CubeBrowser.AppSpot.com www.EasternGraphics.com/X-4GPL
    Last edited by CI-CUBE; 1 Jan 2010, 13:18.

    #2
    Can you try using an explicit rootValue rather than null? For example, the String "root".

    Comment


      #3
      sorry for not mention it, I tried this already but it didn't change anything.

      Further information that might be relevant, or not:

      - if I add a DSCallback parameter to addData it will be called properly
      - the number of TreeGrid elements does not increase (by two) in case of root values
      - an explicit TreeGrid redraw() does not show the add'l nodes

      Cya,

      Ekki

      Comment


        #4
        Ok thanks, we'll see of we can reproduce a general problem with adding root nodes.

        Comment

        Working...
        X