Problem with mRender and Server-Side code
Problem with mRender and Server-Side code
matthttam
Posts: 40Questions: 2Answers: 0
I just converted all my tables from using dynimcally built aoColumns to using aoColumnDefs.
My new table I am adding needs the last row to have a single button in each.
The tables are all initialized the same way and they use this function to define the aoColumnDefs:
[code]
function build_aoColumnDefs(tableID){
aoColDefs = [
{ "mData":0,
"mRender": function(data, type, full){
//create_assign_button(data);
//console.log(type); console.log(full);
return 'Download';
},
"aTargets":["assign_button"]
},
{"bVisible": false, "aTargets":["hidden"]},
{"bSearchable": false, "aTargets":["NoSearch"]},
{"bSearchable": true, "aTargets":["_all"]},
{"bVisible": true, "aTargets":["_all"]}
];
return aoColDefs;
}
[/code]
Here is the table:
[code]
FirstName
LastName
UserName
Grade
AssetTag
Location
Status
Assign
Loading data from server
[/code]
The anonymous function never fires during render. And I get a warning since the json data being generated is from a server-side script that only returns 7 values. I thought mData and mRender would fix this but like I said, the aTarget by class never seems to trigger for some reason.
I need to get this working by Monday at the latest. Could you help me out again :-)
Thanks!
Bil
My new table I am adding needs the last row to have a single button in each.
The tables are all initialized the same way and they use this function to define the aoColumnDefs:
[code]
function build_aoColumnDefs(tableID){
aoColDefs = [
{ "mData":0,
"mRender": function(data, type, full){
//create_assign_button(data);
//console.log(type); console.log(full);
return 'Download';
},
"aTargets":["assign_button"]
},
{"bVisible": false, "aTargets":["hidden"]},
{"bSearchable": false, "aTargets":["NoSearch"]},
{"bSearchable": true, "aTargets":["_all"]},
{"bVisible": true, "aTargets":["_all"]}
];
return aoColDefs;
}
[/code]
Here is the table:
[code]
FirstName
LastName
UserName
Grade
AssetTag
Location
Status
Assign
Loading data from server
[/code]
The anonymous function never fires during render. And I get a warning since the json data being generated is from a server-side script that only returns 7 values. I thought mData and mRender would fix this but like I said, the aTarget by class never seems to trigger for some reason.
I need to get this working by Monday at the latest. Could you help me out again :-)
Thanks!
Bil
This discussion has been closed.
Replies
Allan
It is serverside processing and I can't mimic this very easily using datatables live examples page.
The server data is student information that is sensitive and I cannot use that data on an un password protected site.
This is my code:
http://live.datatables.net/iyekas/edit#javascript,html
It is quite complicated because I am generating 6 tables at once so I made the tables get generated based off a single variable. There is some PHP behind the output you see.
If I am using server-side processing and the data has 7 columns but I want an 8th column that has a button in it. I was trying to do this client side with mRender and mData using a class (since all my tables get the same aoColumnDefs). I may just have to output a button HTML as the data for each row; or is this how it is supposed to be done?
I repeatedly get this warningright now:
DataTables warning (table id = 'Check-out'): Requested unknown parameter '7' from the data source for row 0
after each row data processing to add that html to it. It worked fine.
At least I have a solution for the upcoming event :-). But if you have any light to shed on why mRender and mData don't seem to trigger. I even tried putting 'hidden' as the class for aTarget and removed the hidden definition and the ones that used to be hidden didn't get any changes to their rendering or data.
Allan
Thanks Allan!
You rock.
~Bil