I am using jqGrid to create a web-site, and I'm trying to use the cellattr function to set the 'title' attribute of each cell in first column to a tag defined in an xml file. I have pasted below the javascript I'm using to try and accomplish this, and below that I have included an example of the xml file I'm using with a single record. At the moment, however, it's setting the title attribute to 'undefined'. I have tried various return statements in the cellattr function, including:
return 'title="' + onHoverText + '"';
return 'title="' + rawObject.onHoverText + '"';
return 'title="' + cm[onHoverText] + '"';
with no success. Here is the full javascript code:
Query(document).ready(function() {
jQuery("#list").jqGrid({
xmlreader: {
root:"rows",
row:"row",
repeatitems: false,
onHoverText:"onHoverText"
},
url: "data.xml",
datatype: "xml",
mtype: "GET",
colNames: ["","Bisulfite seq","OxBisulfite seq","Genome seq","H3K27ac","H3K27me3","H3K36me3","H3K4me1","H3K4me3","H3K9ac","H3K9me3","Input DNA Control","mRNA seq","miRNA seq","MRE seq","MeDIP seq"],
colModel: [ { name: "", width: 360, classes: 'ui-state-default', cellattr: function (rowId, val, rawObject, cm, rdata) {
return 'title="' + onHoverText + '"';
}},
{ name: "bisulfite_seq", width: 25, align: "center", classes: "data_cell", sortable: false, cellattr: cellattr_func0 },
{ name: "oxbisulfite_seq", width: 25, align: "center", classes: "data_cell", sortable: false, cellattr: cellattr_func1 },
{ name: "genome_seq", width: 25, align: "center", classes: "data_cell", sortable: false, cellattr: cellattr_func2 },
{ name: "h3k27ac", width: 25, align: "center", classes: "data_cell", sortable: false, cellattr: cellattr_func3 },
{ name: "h3k27me3", width: 25, align: "center", classes: "data_cell", sortable: false, cellattr: cellattr_func4 },
{ name: "h3k36me3", width: 25, align: "center", classes: "data_cell", sortable: false, cellattr: cellattr_func5 },
{ name: "h3k4me1", width: 25, align: "center", classes: "data_cell", sortable: false, cellattr: cellattr_func6 },
{ name: "h3k4me3", width: 25, align: "center", classes: "data_cell", sortable: false, cellattr: cellattr_func7 },
{ name: "h3k9ac", width: 25, align: "center", classes: "data_cell", sortable: false, cellattr: cellattr_func8 },
{ name: "h3k9me3", width: 25, align: "center", classes: "data_cell", sortable: false, cellattr: cellattr_func9 },
{ name: "input_dna_control", width: 25, align: "center", classes: "data_cell", sortable: false, cellattr: cellattr_func10 },
{ name: "mrna_seq", width: 25, align: "center", classes: "data_cell", sortable: false, cellattr: cellattr_func11 },
{ name: "mirna_seq", width: 25, align: "center", classes: "data_cell", sortable: false, cellattr: cellattr_func12 },
{ name: "mre_seq", width: 25, align: "center", classes: "data_cell", sortable: false, cellattr: cellattr_func13 },
{ name: "medip_seq", width: 25, align: "center", classes: "data_cell", sortable: false, cellattr: cellattr_func14 },
],xmlreader: {
root:"rows",
row:"row",
repeatitems: false,
onHoverText:"onHoverText"
},
treeGrid: true,
treeGridModel:'adjacency',
pager: "",
rowNum: 30,
rowList: [30, 60, 90],
sortname: "invid",
sortorder: "desc",
viewrecords: true,
gridview: true,
autoencode: true,
caption: "Epigenomic Data Grid - hg19",
height: "100%",
cellEdit: true,
onCellSelect: function(rowid, iCol, cellcontent, e) {
update_selection(cellcontent, e);
}
});
});
And the XML file looks like this
<?xml version='1.0' encoding='utf-8'?>
<rows>
<page>"page"</page>
<total>TP</total>
<records>99</records>
<row id='0'>
<onHoverText> this is foo </onHoverText>
<cell>d<![CDATA[ Blood]]></cell>
<cell class="has_data in_progress"></cell>
<cell class="has_data in_progress"></cell>
<cell class="has_data CEMT level_0">4</cell>
<cell class="has_data CEMT level_0">11</cell>
<cell class="has_data CEMT level_0">11</cell>
<cell class="has_data CEMT level_0">12</cell>
<cell class="has_data CEMT level_0">12</cell>
<cell class="has_data CEMT level_0">12</cell>
<cell/>
<cell class="has_data CEMT level_0">11</cell>
<cell class="has_data CEMT level_0">11</cell>
<cell class="has_data CEMT level_0">4</cell>
<cell class="has_data CEMT level_0">4</cell>
<cell/>
<cell/>
<cell>0</cell>
<cell></cell>
<cell>false</cell>
<cell>true</cell>
<cell>true</cell>
</row>
</rows>
I was under the impression that there was a function to parse the xml once xmlreader had been defined, but I can't find it. I would appreciate any help.
Note: If anyone wants to see an example of the web-site you can see it at: http://www.bcgsc.ca/downloads/bdavis/tempsite/
Cheers, Brad Davis