Problem with mRender and Server-Side code

Problem with mRender and Server-Side code

matthttammatthttam Posts: 40Questions: 2Answers: 0
edited July 2013 in DataTables 1.9
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

Replies

  • matthttammatthttam Posts: 40Questions: 2Answers: 0
    Should I just make the serverside code return the html needed as data then bind the button with javascript like usual?
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    edited July 2013
    I think I would probably exact that to work at well looking at it. Can you link us to a test case showing the issue please, so I can look at see what is wrong? Also, I'll not be able to help over this coming weekend, as unfortunately I'm traveling.

    Allan
  • matthttammatthttam Posts: 40Questions: 2Answers: 0
    I have been trying to setup a live preview but I am running into a few obstacles.
    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
  • matthttammatthttam Posts: 40Questions: 2Answers: 0
    I went ahead and array_push($row, 'Assign')
    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.
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Unfortunately the live code doesn't render so I can't say what exactly is going wrong. Are you using v1.9.4? mRender / mData were new in 1.9.4 (mData used to be called mDataProp and mRender is wholly new).

    Allan
  • matthttammatthttam Posts: 40Questions: 2Answers: 0
    That is what I didn't know. I probably am using 1.9.0. I am at home now but that does explain the problem precisely.

    Thanks Allan!
    You rock.
    ~Bil
This discussion has been closed.