How to add column to server side data

How to add column to server side data

WeaponX86WeaponX86 Posts: 40Questions: 0Answers: 0
edited August 2012 in DataTables 1.9
I use the following code to hit the server and retrieve the displayed columns before actually drawing the DT. This builds aoColumnDefs and everything in the "done" callback works fine. Adding the last column does absolutely nothing.
[code]
var columns = [];
var aoColumnDefs = [];

jq.ajax({
dataType: "json",
async: false,
url: '<?php echo MOD_URL.CLASS_NAME."/?event=getColumns";?>'
}).done(function(json) {
for (var key in json) {
if (json.hasOwnProperty(key)) {
jq("#work_orders thead tr").append('' + json[key].friendly_name + '');
var title = json[key].friendly_name.replace(/(<([^>]+)>)/ig," ");

var oColumn = {
"aTargets": ['heading_' + key],
"sTitle": title,
"sName": title,
"mData": key,
"sClass": (key == 'wo_status') ? 'wo_status' : '',
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
//console.log(oData)
jq(nTd).wrapInner('');
},
"bSearchable": true
}

aoColumnDefs.push(oColumn);
}

}
});

var oLast = {
"aTargets": ["heading_icons"],
"sTitle": "icons",
"sName": "icons",
"mData": null,
"bSortable": false,
"bSearchable": false,
"fnRender": function ( o, val ) {
return 'Comments Map History';
}
};
aoColumnDefs.push(oLast);
[/code]

Here is the stringified version of the object:
[code]
[
{
"aTargets": [
"heading_wo_status"
],
"sTitle": "Status",
"sName": "Status",
"mData": "wo_status",
"sClass": "wo_status",
"bSearchable": true
},
{
"aTargets": [
"heading_wo_number"
],
"sTitle": "WO #",
"sName": "WO #",
"mData": "wo_number",
"sClass": "",
"bSearchable": true
},
{
"aTargets": [
"heading_org_wo_num"
],
"sTitle": "PPW #",
"sName": "PPW #",
"mData": "org_wo_num",
"sClass": "",
"bSearchable": true
},
{
"aTargets": [
"heading_date_due_print"
],
"sTitle": "Date Due",
"sName": "Date Due",
"mData": "date_due_print",
"sClass": "",
"bSearchable": true
},
{
"aTargets": [
"heading_date_due_client_print"
],
"sTitle": "Client Date Due",
"sName": "Client Date Due",
"mData": "date_due_client_print",
"sClass": "",
"bSearchable": true
},
{
"aTargets": [
"heading_client_company_name"
],
"sTitle": "Client",
"sName": "Client",
"mData": "client_company_name",
"sClass": "",
"bSearchable": true
},
{
"aTargets": [
"heading_customer_name"
],
"sTitle": "Customer",
"sName": "Customer",
"mData": "customer_name",
"sClass": "",
"bSearchable": true
},
{
"aTargets": [
"heading_address"
],
"sTitle": "Address",
"sName": "Address",
"mData": "address",
"sClass": "",
"bSearchable": true
},
{
"aTargets": [
"heading_city"
],
"sTitle": "City",
"sName": "City",
"mData": "city",
"sClass": "",
"bSearchable": true
},
{
"aTargets": [
"heading_state"
],
"sTitle": "State",
"sName": "State",
"mData": "state",
"sClass": "",
"bSearchable": true
},
{
"aTargets": [
"heading_zip"
],
"sTitle": "Zip",
"sName": "Zip",
"mData": "zip",
"sClass": "",
"bSearchable": true
},
{
"aTargets": [
"heading_inspector_name"
],
"sTitle": "Contractor",
"sName": "Contractor",
"mData": "inspector_name",
"sClass": "",
"bSearchable": true
},
{
"aTargets": [
"heading_category_name"
],
"sTitle": "Category",
"sName": "Category",
"mData": "category_name",
"sClass": "",
"bSearchable": true
},
{
"aTargets": [
"heading_admin_name"
],
"sTitle": "Admin",
"sName": "Admin",
"mData": "admin_name",
"sClass": "",
"bSearchable": true
},
{
"aTargets": [
"heading_work_type_name"
],
"sTitle": "Work Type",
"sName": "Work Type",
"mData": "work_type_name",
"sClass": "",
"bSearchable": true
},
{
"aTargets": [
"heading_photos"
],
"sTitle": "Photos",
"sName": "Photos",
"mData": "photos",
"sClass": "",
"bSearchable": true
},
{
"aTargets": [
"heading_icons"
],
"sTitle": "icons",
"sName": "icons",
"mData": null,
"bSortable": false,
"bSearchable": false
}
]
[/code]

Replies

  • WeaponX86WeaponX86 Posts: 40Questions: 0Answers: 0
    Debug data uploaded:
    http://debug.datatables.net/ogitik
This discussion has been closed.