Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Bill Reinke on Nov 24, 2008 17:31
open dhtmlx forum
Dynamic data in a sub grid

Is there a way to generate and populate subgrids dynamically?

Our servers manage nodes on a network. Configuration
can be shared among nodes. We currently use a simple
grid to present configuration data; each row has values that
uniquely identify the configuration (type and name),
and values specific to each node (nodename and state).

    <Type>    <Name>    <Nodename>    <State>
    t1    n1    node1        on
    t1    n2    node1        on
    t1    n2    node2        off
    ...

The presentation in a simple grid is confusing, because
some operations are performed on the configuration
across nodes (i.e. for multiple rows of the table), and
others are performed on a particular config instance
on a particular node (a single row of the table).

A nested grid would be ideal: each row would show
the type and name, and clicking on the row would
open the nodenames and states for that configuration:

    <Type>    <Name>
    t1    n1
    t1    n2 (selected)
        <Nodename>    <State>
        node1        on
        node2        off

This data comes from the server in a single call --
easily parsed into a CSV string to build the simple table
that we use today. But the subgrid in your example:

http://dhtmlx.com/docs/products/docsExplorer/index.shtml?node=dhtmlxgrid&type=smpl

seems to require an xml file (on the server) to define
the subgrid and then additional xml files or URLs to
populate the subgrid.
Answer posted by Support on Nov 25, 2008 02:42
There are two events which can be used to create subgrids on the fly 
   onSubGridCreated
   onSubGridLoaded

onSubGridCreated occurs when subgrid opens and can be used to define custom structure or load custom dataset.

>>This data comes from the server in a single call -- 
>>easily parsed into a CSV string to build the simple table 
>>that we use today. But the subgrid in your example:

By using above event it possible to intercept the moment of subgrid creation and load some custom data in it, but it still require some customization to loaded data, because grid will not be able to separate a single dataset between main grid and subgrids. 

The alternative solution may be a usage of tree-grid component, which allow to define necessary hierarchy directly in dataset and just load it as single file without any additional coding.