Need to use ajax server rendering with empty table

Need to use ajax server rendering with empty table

WeaponX86WeaponX86 Posts: 40Questions: 0Answers: 0
edited July 2012 in General
Using server side processing I need to render column headings on the fly with some kind of callback when the ajax call is successful.

I searched and found this:
http://datatables.net/forums/discussion/3442/x&page=1#Item_10

But this will break the server side rendering.

Something like this:

[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Untitled Document

var display_options = {"wo_status":"Status","wo_number":"WO #","org_wo_num":"PPW #","date_created_print":"Date Created","date_received_print":"Date Received","ready_submission_date_print":"Ready Office","date_due_print":"Date Due","date_due_client_print":"Client Date Due","date_complete_estimate_print":"Estimated Complete Date","date_cancel_print":"Cancel Date","client_company_name":"Client","customer_name":"Customer","loan_number":"Loan #","loan_type":"Loan Type","address":"Address","city":"City","state":"State","zip":"Zip","county":"County","lot_size":"Lot Size","lock_code":"Lock Code","inspector_name":"Contractor","category_name":"Category","admin_name":"Admin","work_type_name":"Work Type","invoice_num":"Invoice #","invoice_date_print":"Invoice Date","photos":"Photos"};


var oTable = jq('#work_orders').dataTable({
"bStateSave": true,
//"aaData": json_arr,
//"aoColumns": aoColumns,
"bDeferRender": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": '<?php echo APP_URL."myhome/myhome_beta_test/?event=filterAjax";?>',

// Need a function like this to render column headings before further processing
"fnAjaxSuccess": function(aoData){
//Loop through headings sent from aoData

var columns = [];
// Look at first row sent down for columns
for (column in aoData[0]){
columns.push(column);
}

//Loop through sent headings, create aoColumns
for (var i=0;i -1) ? 'us_date' : '';
//oColumn.sDefaultContent = 'TEST';
oColumn.fnCreatedCell = function (nTd, sData, oData, iRow, iCol) {
//jq(nTd).wrapInner('');
}

if (typeof oColumn.sTitle != "undefined"){
oColumn.sTitle = oColumn.sTitle.replace(/(<([^>]+)>)/ig," ");
}

oColumn.bVisible = (jQuery.inArray(columns[i], hidden_columns) > -1) ? false : true;
oColumn.bSearchable = true;

aoColumns.push(oColumn);
}
}
});









[/code]
This discussion has been closed.