title: How to enlist children of specified Parent in treeview colum (table)
body: <p>I am newbie in grails and tried to implement treeview using RichUI plugin, which shows all parents with individual children in Parent.list.gsp</p>
  
  <p><strong>xml for parent and their children</strong> </p>
  
  <pre><code>     &lt;parents name='Parents'&gt;
    &lt;Parent id='1' name='Parent_1'&gt;
      &lt;Children name='Children'&gt;
        &lt;child name='Child_2' id='2' /&gt;
        &lt;child name='Child_4' id='4' /&gt;
        &lt;child name='Child_1' id='3' /&gt;
        &lt;child name='Child_3' id='1' /&gt;
      &lt;/Children&gt;
    &lt;/Parent&gt;
    &lt;Parent id='2' name='Parent_2'&gt;
      &lt;Children name='Children'&gt;
        &lt;child name='Child_1' id='8' /&gt;
        &lt;child name='Child_2' id='7' /&gt;
        &lt;child name='Child_4' id='6' /&gt;
        &lt;child name='Child_3' id='5' /&gt;
      &lt;/Children&gt;
    &lt;/Parent&gt;
  &lt;/parents&gt;
  </code></pre>
  
  <p><strong>Parent Domain Class</strong> </p>
  
  <pre><code>class Parent {
  
  String name
  
  static hasMany = [children:Child]
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Child Domain Class</strong></p>
  
  <pre><code>class Child {
  
      String name
      Parent parent
  
      static belongsTo = [parent:Parent]
  
  }
  </code></pre>
  
  <p><strong>Parent Controller</strong></p>
  
  <pre><code>def list = {
  
      def writer = new StringWriter()
      def xml = new MarkupBuilder(writer)
      xml.parents(name: "Parents"){
          Parent.list().each {
              Parent parentt = it
              Parent( id:parentt.id,name:parentt.name) {
                  Children(name:'Children'){
                      parentt.children.each {
                          Child childd = it
                          child(name:childd.name,id:childd.id)
                      }
                  }
              }
          }
      }
      if(!params.max)params.max=10
      ["data":writer.toString(),parentInstanceList: Parent.list(params), parentInstanceTotal: Parent.count()]
  }
  </code></pre>
  
  <p><strong>Parent.list.gsp</strong></p>
  
  <pre><code> &lt;head&gt;
      &lt;resource:treeView/&gt; ...&lt;/head&gt;
  
   &lt;body&gt;
     &lt;table&gt;
                  &lt;thead&gt;
                      &lt;tr&gt;
  
                          &lt;g:sortableColumn property="id" title="${message(code: 'parent.id.label', default: 'Id')}" /&gt;
  
                          &lt;g:sortableColumn property="name" title="${message(code: 'parent.name.label', default: 'Name')}" /&gt;
                          &lt;g:sortableColumn property="relationship" title="${message(code: 'parent.relationhsip.label', default: 'Relationship')}" /&gt;
  
                      &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;
                  &lt;g:each in="${parentInstanceList}" status="i" var="parentInstance"&gt;
                      &lt;tr class="${(i % 2) == 0 ? 'odd' : 'even'}"&gt;
  
                          &lt;td&gt;&lt;g:link action="show" id="${parentInstance.id}"&gt;${fieldValue(bean: parentInstance, field: "id")}&lt;/g:link&gt;&lt;/td&gt;
                          &lt;td&gt;${fieldValue(bean: parentInstance, field: "name")}&lt;/td&gt;
                          &lt;td&gt;&lt;richui:treeView  xml="${data}" /&gt;&lt;/td&gt;
  
                      &lt;/tr&gt;
                  &lt;/g:each&gt;
                  &lt;/tbody&gt;
              &lt;/table&gt;
  
   &lt;/body&gt;
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>Currently, in list view, every Parent entry has list of all parents and their children under
  relationship column</p>
  
  <p>Parent List view Snapshot <a href="http://img232.imageshack.us/img232/6326/parentlistview.png" rel="nofollow">link text</a></p>
  
  <p><strong>Question</strong></p>
  
  <p>how can i enlist all children only for each parent instead of enlisting all parents with their children in each Parent entry ? </p>
  
  <p>thanks in advance</p>
  
  <p>Rehman</p>