Dynamic column title doesn't appear in xl, pdf
Dynamic column title doesn't appear in xl, pdf
rajarajananis
Posts: 29Questions: 0Answers: 0
Hi all,
First of all I wanna say thanks for your amazing datatable plugin. And, Please say something about my question. This is my third question, but unfortunately no replies yet. I really do not know why. Ok come to my subject.
I have a scenario here. My datatable contains dynamic visible columns that depend on user needs. And , column headers are dynamic, and fetched from Ajax source. so In order to show dynamic column title I use this code.
oTable.fnSettings().aoColumns[13].nTh.innerHTML = results[0].xxx.title1;
The problem is that while export to xl this column header does not appear in xl, pdf.. and In addition to that I have a width problem when I export large amount of columns.. Let's assume that no of columns are 45..
so anybody can help me? please.!!
First of all I wanna say thanks for your amazing datatable plugin. And, Please say something about my question. This is my third question, but unfortunately no replies yet. I really do not know why. Ok come to my subject.
I have a scenario here. My datatable contains dynamic visible columns that depend on user needs. And , column headers are dynamic, and fetched from Ajax source. so In order to show dynamic column title I use this code.
oTable.fnSettings().aoColumns[13].nTh.innerHTML = results[0].xxx.title1;
The problem is that while export to xl this column header does not appear in xl, pdf.. and In addition to that I have a width problem when I export large amount of columns.. Let's assume that no of columns are 45..
so anybody can help me? please.!!
This discussion has been closed.
Replies
var caseID = 0, isUDF = 0;
var searchTable = new Object();
$(document).ready(function () {
BindCaseMemberTable("");
});
function DetermineUDF(results) {
BindCaseMemberTable(results);
if (isUDF == 1) {
$.ajax({
type: "POST",
url: "HttpHandler/CaseMemberSearchHandler.ashx?fc=CaseUDFFields&CaseID=" + caseID,
data: {},
dataType: "json",
contentType: "application/json",
responseType: "json",
success: function (response) {
SetColumnHeader(response);
}
});
for (var i = 13; i <= 57; i++) {
var bVis = searchTable.fnSettings().aoColumns[i].bVisible;
searchTable.fnSetColumnVis(i, bVis ? false : true);
}
}
else {
alert("last fired");
document.getElementById('CaseMemberSearchTable').style.width = "1200px";
document.getElementById('CaseMemberSearchTable_wrapper').style.width = "1200px";
}
}
function SetColumnHeader(results) {
searchTable.fnSettings().aoColumns[13].nTh.innerHTML = results[0].CaseDataFieldTitles.title1;
searchTable.fnSettings().aoColumns[14].nTh.innerHTML = results[0].CaseDataFieldTitles.title2;
searchTable.fnSettings().aoColumns[15].nTh.innerHTML = results[0].CaseDataFieldTitles.title3;
searchTable.fnSettings().aoColumns[16].nTh.innerHTML = results[0].CaseDataFieldTitles.title4;
document.getElementById('CaseMemberSearchTable').style.width = "5800px";
document.getElementById('CaseMemberSearchTable_wrapper').style.width = "5800px";
}
function BindCaseMemberTable(results) {
searchTable = $('#CaseMemberSearchTable').dataTable(
{
//"sDom": 'T<"clear">lfrtip',
"sDom": 'T<"clear"><"H"lfr>t<"F"ip>',
"oTableTools": {
"sSwfPath": "App_Themes/defaultNew/DataTables/swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "csv",
"mColumns": "visible"
},
{
"sExtends": "xls",
"mColumns": "visible"
}
]
},
"bDestroy": true,
"oLanguage": {
"sEmptyTable": "No Data"
},
"aaData": results,
"bProcessing": true,
"bAutoWidth": false,
"aoColumns": [
{ "mData": "PersonID", "bSearchable": true, "bVisible": false, "sWidth": "2" },
{ "mData": null, "sTitle": "View", "bSortable": false, "sWidth": "30", "mRender": function (data, type, full) {
return 'View '
}
},
{ "mData": "SIMID", "sTitle": "SIM ID", "sWidth": "60" },
{ "mData": "FirstName", "sTitle": "First Name", "sWidth": "100" },
{ "mData": "LastName", "sTitle": "Last Name", "sWidth": "100" },
{ "mData": "BusinessName", "sTitle": "Business Name", "sWidth": "180" },
{ "mData": "TIN", "sTitle": "TIN No", "sWidth": "80" },
{ "mData": "PersonStatus", "sTitle": "Person
Status", "sWidth": "80" },
{ "mData": "Address1", "sTitle": "Address", "sWidth": "180" },
{ "mData": "City", "sTitle": "City", "sWidth": "120" },
{ "mData": "StateTitle", "sTitle": "State", "sWidth": "150" },
{ "mData": "Zip", "sTitle": "Zip", "sWidth": "40" },
{ "mData": "SAS", "sTitle": "SAS", "sWidth": "100" },
{ "mData": "DataField1", "sDefaultContent": "", "bVisible": false },
{ "mData": "DataField2", "sDefaultContent": "", "bVisible": false },
{ "mData": "DataField3", "sDefaultContent": "", "bVisible": false },
{ "mData": "DataField4", "sDefaultContent": "", "bVisible": false },
{ "mData": "DataField5", "sDefaultContent": "", "bVisible": false },
{ "mData": "DataField6", "sDefaultContent": "", "bVisible": false },
{ "mData": "DataField7", "sDefaultContent": "", "bVisible": false }
{ "mData": "DataField8", "sDefaultContent": "", "bVisible": false },
{ "mData": "DataField17", "sDefaultContent": "", "bVisible": false },
{ "mData": "DataField18", "sDefaultContent": "", "bVisible": false }