Hi Hristo,
Finally i am able to populate the table but still unable to load dynamic columns. when i hard code the columns, it works but not the dynamic way.
Please suggest!
Thanks,
SJ
json:
readDatViewFilejsonArray{
“columns”: [{
“datafield”: “PATCD”,
“text”: “PATCD”,
“width”: 100
},
{
“datafield”: “AETERM”,
“text”: “AETERM”,
“width”: 100
},
{
“datafield”: “AEBODSYS”,
“text”: “AEBODSYS”,
“width”: 220
}],
“rows”: [{
“PATCD”: “0”,
“AETERM”: “0001”,
“AEBODSYS”: “1”
},
{
“PATCD”: “1”,
“AETERM”: “0002”,
“AEBODSYS”: “2”
},
{
“PATCD”: “0”,
“AETERM”: “0004”,
“AEBODSYS”: “1”
}]
}
Code:
var source = {
dataType : “json”,
url : “readDatViewFile.do”
};
var columns;
var dataAdapter = new $.jqx.dataAdapter(source, {
formatData : function(data) {
data.$skip = data.pagenum * data.pagesize;
data.$top = data.pagesize;
data.$inlinecount = “allpages”;
return data.rows;
},
downloadComplete : function(data, status, xhr) {
if (!source.totalRecords) {
source.totalRecords = data.rows.length;
}
},
loadError : function(xhr, status, error) {
throw new Error(“http://services.odata.org: ” + error.toString());
},
beforeLoadComplete : function(records, original) {
columns = original.columns;
return original.rows;
}
});
$(“#viewDataTable”).jqxDataTable({
width : ‘99%’,
theme : ‘bootstrap’,
autoRowHeight : true,
altRows : true,
height : “98%”,
columnsHeight : 50,
source : dataAdapter,
sortable : true,
editable : false,
columnsResize : true,
columns : columns,//not work:dynamic
columns : [ {//worked
text : ‘PATCD’,
dataField : ‘PATCD’,
width : 100,
filterable : false,
editable : false
}, {
text : ‘AETERM’,
dataField : ‘AETERM’,
width : 100,
editable : false
} ],
pageable : true,
pageSize : 100,
pagerButtonsCount : 5,
serverProcessing : true,
filterable : true,
filterMode : ‘simple’
});