Announcement

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

    TreeGrid data structure compatibility

    Environment:
    Using SmartGWT3.1 on Eclipse Juno.

    Problem:
    I´m trying to show a data table on a TreeGrid view. The key point is that my data structure is like the figure Table.jpg attached (a print copy of MySql wokbench).

    The columns are identified at first line, as follows:
    Cloumn #1 = "codigo" is the unique primaryKey
    almost all other columns are basically references to foreign keys.

    The hierarchy relationship is among field "subCatego" (6th column at picture) and "alinea" (9th column).

    I could make it present the root level as at attached figure tree_1.jpg. But when selecting any value the TreeGrid is updated and the selected item is removed from it, in opossite as expected to present its chield records.
    I can trace the full cycle with fetching database and so on, and see that it returns at least 2 chield records for the first option ("1900000-OUTRAS RECEITAS...")

    Here is the DS XML definition I´m using:

    Code:
    	<fields>
    		<field name="codigo"         type="integer"  primaryKey="true" hidden="true"></field>
    		
    				
    	    <field name="subCat"         includeFrom="codigoTipoReceita_DS.nome"  ></field> 
    	    
    	    <field name="aln"  includeFrom="classificacaoReceita_DS.nome"  ></field> 
    
    		<field name="subCategoria"   type="integer"  foreignKey="codigoTipoReceita_DS.codigo"  hidden="true"></field>
    		<field name="alinea"         type="integer"  foreignKey="classificacaoReceita_DS.codigo" hidden="true" ></field>
    
    
    		<field name="fonte"          type="integer"></field>
    		<field name="rubrica"        type="integer"></field>
    
    		<field name="prefeitura"     type="integer"  foreignKey="prefeituras.codigo" hidden="true"></field>
    		<field name="orgao"          type="integer"  foreignKey="orgaos.codigo" hidden="true"></field>
    		
    		<field name="fonteRecurso"   type="integer"  foreignKey="codigoFonteRecurso_DS.codigo" hidden="true"></field>
    	    <field name="recurso"        includeFrom="codigoFonteRecurso_DS.nome"  hidden="true"></field> 
    				
    		
    		<field name="aplicacaoFixo"  type="integer"  foreignKey="codigoAplicacao_DS.codigoFico" hidden="true"></field>
    	    <field name="aplic"          includeFrom="codigoAplicacao_DS.nome" hidden="true" ></field>

    Since my data structure is not exactly as "parent-linked" I´m using DMI to manage it as recommended at Interface TreeDataBinding documentation. The logic in my DMI is pretty simple:
    1- for any fetch request it gets the "subCatego" value from parentNode,
    2- updates DSRequest including this "subCatego" as criteria
    3- and fetchs the database.

    obs- I´m also using embedded joins to retrieve some additional text. For example the text "190000-OUTRAS RECEITAS..." comes from foreign table.

    Since my data is not "parent-linked" it sounds me the proper mode to use would be "CHILDREN". Could you please confirm if it´s correct and also please provide some hints on how to set it on the TreeGrid instance.

    appreciate by your support
    Conejo
    Attached Files
    Last edited by conejo; 27 Feb 2013, 10:56.

    #2
    Little progress from yesterday.

    Basically I´ve created a customized record data at fetchDMI. It has only the node title value to be shown at TreeGrid.

    It worked well for the root level but at chield level it presents the value as "Untitled" at tree (you can see it at "tree_2.jpg" picture.

    At TreeGrid level I can check that all expected nodes are returned from server side after fetch by intercepting the onDataArrived method.

    So my question now is how to make the proper values be shown at TreeGrid instead of "Untitled" .
    Attached Files

    Comment


      #3
      Believe I´ve figured out it.

      At onDataArrived method I´m forcing the node title contents. And Tree shows it at children level.

      Is this the correct (i.e. the best) way for doing it?
      Last edited by conejo; 28 Feb 2013, 10:12.

      Comment

      Working...
      X