...
- From the Weave client, make note of the Active Layer for which you want to create a Data Grid. Note also the
datasource
value (from thedatasource.xml
file), database schema name and table name.
- Open your
data.xml
file for editing. This file will contain other Data Grids that have been configured for your site.
A new Data Definition needs to be created as this is what dictates which fields will be shown in the Data Grid. If you are familiar with the fields you want in the Data Grid, you can use the other Data Definitions as a guide and add in as many
parameter
XML Entity lines that you need. However an easier way is to use the Administration Tool Console window or Weave's OSGi console (this will save you some typing and reduces the likelihood of a typing mistake). In the console, run thedbmd
command with the details of the table you want to report on.Code Block dbmd conf <datasource> <table> <schema> (schema name is not needed if table name is unique in the database) e.g.: dbmd conf gis counciltrees
Copy the XML generated at Step 3 into the
data.xml
file. Notice there are someFIX_ME
values that need to be updated, i.e. you will need to give the Data Definition an identifier (with theid
XML Attribute) and supply the key field (with thekey
XML Attribute). This is shown in the example below.Code Block title Raw XML as output from the dbmd command: <data:datadefinition id='FIX_ME'> <datasourcedataconnection key='FIX_ME' table='mann.counciltrees' datasource='gis'> <parameter name='fid' label='FID' column='fid' type='int'/> <parameter name='tree_no' label='Tree No.' column='tree_no' type='float'/> <parameter name='species' label='Species' column='species'/> <parameter name='height' label='Height' column='height'/> <parameter name='dbh' label='DBH' column='dbh'/> <parameter name='hazard' label='Hazard' column='hazard'/> <parameter name='condition' label='Condition' column='condition'/> </datasourcedataconnection> </data:datadefinition>
Code Block title Updated XML ready for use: <data:datadefinition id='counciltrees'> <datasourcedataconnection key='fid' table='mann.counciltrees' datasource='gis'> <parameter name='fid' label='FID' column='fid' type='int' /> <parameter name='tree_no' label='Tree No.' column='tree_no' type='float'/> <parameter name='species' label='Species' column='species'/> <parameter name='height' label='Height' column='height'/> <parameter name='dbh' label='DBH' column='dbh'/> <parameter name='hazard' label='Hazard' column='hazard'/> <parameter name='condition' label='Condition' column='condition'/> </datasourcedataconnection> </data:datadefinition>
The output from the
dbmd
command reports on all the fields from the table so delete or comment out any lines that you do not want to include in the Data Grid. If you want all the fields to appear in the Data Grid, then you can delete all the parameter lines. By default, all fields from the table will be displayed in the Data Grid when no fields are given as shown below.Code Block <data:datadefinition id='counciltrees'> <datasourcedataconnection key='fid' table='mann.counciltrees' datasource='gis'/> </data:datadefinition>
Some Weave practitioners use the “
dd_
” prefix as their naming convention for Data Definitions. This is not necessary as long as there are no other Data Definitions with the sameid
value. However if your Weave configuration is using the "dd_
" prefix, or another naming convention, then for consistency it is best to continue using this convention.
Add a
data:data
XML Element to link the Data Definition (defined above) to the Entity (from theentity.xml
file) as shown below.Code Block <data:data id="counciltrees" label="Council Trees" entity="counciltrees" datadefinition="counciltrees" />
This has now set up a Data Definition that will be used in the Data Grid when a Search is run or the Identify tool is used.
Often, you’ll want to display fields from more than one table or database in your Data Grid, particularly if you want to link spatial features to data stored in an aspatial database. This can be done by adding a
from
andwhere
clause in thedata:datadefinition
XML Tag before listing the fields to retrieve. It’s best to fully qualify the field in thecolumn
XML Attribute when reading from more than one table, i.e.<schema>.<table>.<field>.
In the example below additional fields are being read from the same database but a different schema and table (i.e. datasource =gis
, schema =cid
, table =treedetails
). (Note, you can only use a table from a second database if that table is known to the first database.)Code Block <data:datadefinition id='counciltrees'> <datasourcedataconnection key='fid' table='mann.counciltrees' datasource='gis'> <from table="cid.treedetails"/> <where clause="cid.treedetails.fid=mann.counciltrees.fid"/> <parameter name='fid' label='FID' column='fid' type='int' /> <parameter name='tree_no' label='Tree No.' column='tree_no' type='float'/> ... <parameter name='condition' label='Condition' column='condition'/> <parameter name='priority' label='Priority' column='priority'/> </datasourcedataconnection> </data:datadefinition>
The Data Sources Tool in the Administration Tool reports on the tables that you can use in Data Definitions (and thus Data Grids). It is useful to explore data and check field names, etc. for data you wish to include in a Data Grid.
...