How do you get cells value and pass it to the aoColumns?
How do you get cells value and pass it to the aoColumns?
Hi,
I am using sAjaxSource to call a file that has the values and generates the table. I am looking to grab the data in the first cell in the row for each row.
How do you go about getting a cell's data/text and passing it to the aoColumns return value?
"aoColumns": [null, null, { "bSortable": false,"fnRender": function(oObj) {
return 'Put value from cell here';
}
}]
I have tried the fnRowCallback, which I can then get the value I need, but I can't seem to pass that back to the aoColumns since the variable is in that function.
I have also tried using Jquery to grab the cell data but it always comes back as null or nothing.
I am probably missing something really simple.
Any help would be greatly appreciated.
I am using sAjaxSource to call a file that has the values and generates the table. I am looking to grab the data in the first cell in the row for each row.
How do you go about getting a cell's data/text and passing it to the aoColumns return value?
"aoColumns": [null, null, { "bSortable": false,"fnRender": function(oObj) {
return 'Put value from cell here';
}
}]
I have tried the fnRowCallback, which I can then get the value I need, but I can't seem to pass that back to the aoColumns since the variable is in that function.
I have also tried using Jquery to grab the cell data but it always comes back as null or nothing.
I am probably missing something really simple.
Any help would be greatly appreciated.
This discussion has been closed.
Replies
If I understand the issue correctly, what you want to do is use some of the information from a specific row, in the fnRender function - is that correct? If so - it looks like you are most of the way to a solution! What you need to do to complete the code, is use the information in oObj. If you have a look at the documentation, you will be able see what information is available: http://datatables.net/usage/columns#fnRender
Specifically, what you will want to some like using the variable 'oObj.aData[0]' to get the cell information for the first cell in that row.
Regards,
Allan
Keep up the good work.
I knew I was close. I tried everything but the oObj.aData. So here is what it now looks like in case anyone else is looking for the same info.
"aoColumns": [null, null, { "bSortable": false,"fnRender": function(oObj) {
// oObj.aData[0] grabs the first cell's data in the row
var cId = oObj.aData[0];
return ''+cId+'';
}
}]