fnRender issue with 1.8
fnRender issue with 1.8
numberone
Posts: 86Questions: 0Answers: 0
hi,
this is not working after the lib updated. it seems like a bug.
[code]
var activated=new Array("Inactive","Active");
.
.
{ "sName": "activated", "fnRender": function (oObj){return activated[oObj.aData[4]];} },
[/code]
it returns "undefined" . its working with 1.7.6 without problem.
Thanks.
this is not working after the lib updated. it seems like a bug.
[code]
var activated=new Array("Inactive","Active");
.
.
{ "sName": "activated", "fnRender": function (oObj){return activated[oObj.aData[4]];} },
[/code]
it returns "undefined" . its working with 1.7.6 without problem.
Thanks.
This discussion has been closed.
Replies
Thanks,
Allan
activated[1] works
oObj.aData[4] this one returns 0 or 1
but activated[oObj.aData[4]] returns undefined. :S
var activated=new Array(2,3,"Inactive","Active");
it is meaningless.im sure that something wrong with fnRender..
it is something returns like "activated[ activated[0] ]" or "activated[ activated[1] ]"
while using activated[oObj.aData[4]]
thanx for help ^^
[code]
console.log( '{'+oObj.aData[4]+'}' );
[/code]
Allan
console.log( '{'+oObj.aData[4]+'}' );
{1}
{_firebugIgnore}
{0}
{_firebugIgnore}
{1}
{_firebugIgnore}
{1}
{_firebugIgnore}
..
console.log( '{'+activated[ oObj.aData[4] ]+'}' );
{Active}
{undefined}
{Active}
{undefined}
{Inactive}
{undefined}
{Active}
{undefined}
{Active}
{undefined}
{Active}
{undefined}
{Active}
{undefined}
I've just tried this:
[code]
$(document).ready(function() {
var a = [ "zero", "one" ];
$('#example').dataTable( {
"aoColumnDefs": [
{
"fnRender": function (o) {
return a[ o.aData[0] ];
},
"aTargets": [1]
}
]
} );
} );
[/code]
With this table:
[code]
first
second
0
1
1
0
[/code]
and it seems to work absolutely fine. No errors or weird behaviour in Safari or Firefox.
Could you post either a link to your page, or your full initialisation code please?
Allan
[code]
$(document).ready(function () {
var activated = ["Inactive","Active"];
var banned = ["Active","Banned"];
$('#usertable').dataTable({
'bProcessing' : true,
'bServerSide' : true,
'sAjaxSource' : '<?php echo base_url(); ?>admin/users/getusers_byajax',
"sPaginationType": "full_numbers",
"bAutoWidth": false,
"aoColumns": [
{ "sName": "users.id", "bVisible": false },
{ "sName": "users.username" },
{ "sName": "users.email"},
{ "sName": "user_groups.group_name" },
{ "sName": "users.activated", "fnRender": function (o){ return activated[o.aData[4] ] ;} },
{ "sName": "users.banned", "fnRender": function (o){return banned[o.aData[5]] ;} },
{ "sName": "edit", "bSortable": false },
{ "sName": "delete", "bSortable": false },
],
'fnServerData': function(sSource, aoData, fnCallback)
{
$.ajax
({
'dataType': 'json',
'type' : 'POST',
'url' : sSource,
'data' : aoData,
'success' : fnCallback
});
},
});
});
Kullan?c?lar
ID
Username
Email
Plevel
Activated
Banned
Edit
Delete
loading..
[/code]
and my json :
[code]
{"sEcho":1,"iTotalRecords":"7","iTotalDisplayRecords":"7","aaData":[["1","numberone","n1@test.com","1","0","SuperAdmin","D\u00fczenle<\/a>","Sil<\/a>"],["2","admin","admin@admin.com","1","0","Admin","D\u00fczenle<\/a>","Sil<\/a>"],["3","testuser","testuser@test.com","0","0","User","D\u00fczenle<\/a>","Sil<\/a>"],["4","badguy","badguy@badguy.com","1","1","User","D\u00fczenle<\/a>","Sil<\/a>"],["5","test","test@test.com","1","0","User","D\u00fczenle<\/a>","Sil<\/a>"],["6","fw","fw@bunebune.com","1","0","User","D\u00fczenle<\/a>","Sil<\/a>"],["7","user","email@email.com","1","0","User","D\u00fczenle<\/a>","Sil<\/a>"]],"sColumns":"users.id,users.username,users.email,users.activated,users.banned,user_groups.group_name,edit,delete"}
[/code]
[code]
"bUseRendered": false,
[/code]
to your column definition for the column with the rendering function and let me know what the result is?
I think the issue is that fnRender is being called twice with server-side processing in 1.8 (intentionally so, but this is an unintentional side effect).
Thanks,
Allan
i added "bUseRendered": false to the columns and it worked well.
Regards,
Yusuf
[code]
"aoColumnDefs": [
{ "mDataProp": "Select",
"fnRender" : function ( oObj ) {
console.log(oObj.aData[0]);
console.log(oObj.aData[oObj.oSettings.aoColumns[oObj.iDataColumn].mDataProp]);
return ' ';
},
"bUseRendered": false,
"aTargets": [ 0 ]
},
{ "mDataProp": "userName",
"aTargets": [ 1 ] },
{ "mDataProp": "loginTime",
"aTargets": [ 2 ] }
],
"fnDrawCallback": function() {
persistChecked();
}
[/code]