Fill aoColumns by AJAX call

Fill aoColumns by AJAX call

jabberjabber Posts: 23Questions: 1Answers: 0
edited December 2012 in General
I'm trying to create a parametric datatables app (getting all columns property from database table) and i like also to hide columns names (i don't want to see column name in JS source code)
In order by to reach my target i'm trying to get columns properties by AJAX call.
I've already read these 2 threads:
1) http://www.datatables.net/forums/discussion/3519/getting-column-names-from-ajax-source/p1
2) http://datatables.net/forums/discussion/3442/x&page=1#Item_10

Allan suggests a method that allows to realize all this by a single AJAX call.
This is very good, but I'd like to understand a little matter.
See the code:
[code]
"aoColumnDefs": [
{
"aTargets": [ 0, 1, 2, 3, 4, 5 ],
"mData": function (source, type, val) { // this function runs roughly 1250 times: my table have 40 rows and 6 columns
var oooo = source;
var str="";
for(var key in oooo){ str+=key+" : "+oooo[key]+"\n"; };
alert(str);
}
}
]
[/code]

When i watch "str" string i can see table fields names (and its value), e.g.:
id_item : SD584
height: 20
width:30

For example, if i change id_item in database table, i can see new name instead of id_item directly here, in "str" string.
Then i would post my question, if datatables framework already know table fields names, why do i get to request them by an explicit AJAX call ? Why can't i use these values to set "aoColumns" property?

Replies

  • ChemonChemon Posts: 19Questions: 0Answers: 0
    Is me or many people with same problem ?

    We want to change oSettings properties like aoColumn with each server call.
    Like for example, with diferent aplication user, u need to show diferent amount of columns or some columns must not be editables or some other diferent things.

    I want to know if this can be maden and how, some advices, pls. ty.
This discussion has been closed.