This section describes how to use asynchronous table web library API and functionality.
In order to read in the xml data into the API the input data needs to have 4 levels.
Root
Table
Row
Columns
The Root node is required as input
<tableroot>
<tablename>
<tablerow>
<tablecolumns>
</tablecolumns>
</tablerow>
</tablename>
</tableroot>
mapping_name = [[ HTML_Column_name, XML_Column_name, column_control,null]]
Example mapping,
mapping = [[ '', 'PROPID','radioid',null],['PROPID','PROPID','',null]]
Bringing it all together, with the tabledata function below,
function tabledata(xml) {
parser = new DOMParser();
xmlDoc = parser.parseFromString(xml,"text/xml");
console.dirxml(xmlDoc);
// Root node = response
var message1 = xmlDoc.getElementsByTagName('response')[0];
console.dirxml(message1);
console.dir(message1);
// User defined functions to be activated on certain events :
// oncheck , onuncheck and onclickrow
var userfnlist = {
oncheck : 'checkmain',
onuncheck : 'null',
onclickrow : 'null',
rankcol : ''
}
var tableop = "refresh";
var tabledata = message1;
console.dirxml(tabledata);
var mapping = null;
mapping = [
[
'date',
'date',
'',
null],
[
'hdurl',
'hdurl',
'image',
null],
[
'explanation',
'explanation',
'',
null],
[
'URL',
'URL',
'',
null
]
];
// Append result to HTML component. In this case it is output
// API asynctable parameters
// 1. tabledata
// 2. 'maintable' is the HTML table name
// 3. mapping table structure tying the incoming XML with the
// table structure
$("#output")
.append( asynctable(
tabledata,
'maintable',
mapping,
tableop,
'1', userfnlist));
tablePaginater
.init('maintable');
fdTableSort
.init('maintable');
}