mDataprop + paging + searching + server-side
mDataprop + paging + searching + server-side
Is it possible to send data of selected columns that has mDataprop ?
im trying to make a query for paging and searching but couldnt identify the column on server side.
it would be great if we could have sent something like :
sDataprop : 'username, email, blabla' only selected elements here with the order, like sColumns.
what do you think ?
or is there another alternative to do that ?
Thanks.
im trying to make a query for paging and searching but couldnt identify the column on server side.
it would be great if we could have sent something like :
sDataprop : 'username, email, blabla' only selected elements here with the order, like sColumns.
what do you think ?
or is there another alternative to do that ?
Thanks.
This discussion has been closed.
Replies
Allan
[code]
[
{ "id": "1",
"username": "Orion",
"email": "johndoe@email.com",
"group_name": "User"
},
{ "id": "2",
"username": "Saturn",
"email": "saturn@email.com",
"group_name": "User"
}
]
[/code]
and my table has 3 columns with this column order:
[code]
"aoColumns": [
{ "mDataProp": "group_name" },
{ "mDataProp": "username" },
{ "mDataProp": "email"},
],
[/code]
so, when i try ordering by group_name, at server-side iSortCol_0 equals to zero.
i want to sent a data like
[code]
sDataprop : 'group_name, username, email'
[/code]
so i can handle it like :
[code]
mDataprop = explode(',' , $_POST['sDataprop']);
$order_by = mDataprop[ $_POST['iSortCol_0'] ]; // $order_by will be group_name
[/code]
[code]
'fnServerData': function(sSource, aoData, fnCallback)
{
aoData.push( { "name": "sDataprop", "value": "group_name,username,email" } );
$.ajax
({
'dataType': 'json',
'type' : 'POST',
'url' : sSource,
'data' : aoData,
'success' : fnCallback
});
},
});
[/code]
it would be nice if we had have that by default ^^
again thank you very much.
Allan
Whatever, ty for ur reply.
could you gimme an example how can i use both mDataprop and sName together ?
? couldnt make it work :(
thanks
[code]
{ "mDataProp": "name", "sName": "name" },
...
[/code]
Then the server will be able to figure out which column is which. Of course since you are using objects in the return then it's not important in the returned JSON since DataTables will do the mapping automatically.
Allan