mDataProp (Dynamic column properties) using Serverside Processing
mDataProp (Dynamic column properties) using Serverside Processing
johnadamsy
Posts: 13Questions: 0Answers: 0
Hi Allan,
Glad to have made greater progress with this plugin.
I am using multiple tables on a single page, and I don't want to keep rewriting this part or rather the whole datable initialization code:
[code]"aoColumns": [
{ "mDataProp": "engine" },
{ "mDataProp": "browser" },
{ "mDataProp": "platform" },
{ "mDataProp": "version" },
{ "mDataProp": "grade" }
][/code]
I have seen the function, but it rather, doesn't bring out the concept clearly...How would I use javascript to define the columns dynamically...table x has the following column definitions [code]{ "mDataProp": "fname" },
{ "mDataProp": "lname" },
{ "mDataProp": "age" },
{ "mDataProp": "dob" },
{ "mDataProp": "grade" }[/code] and another table y have the following:
[code]
{ "mDataProp": "item_code" },
{ "mDataProp": "name" },
{ "mDataProp": "quantity" },
{ "mDataProp": "price" }
[/code]
Glad to have made greater progress with this plugin.
I am using multiple tables on a single page, and I don't want to keep rewriting this part or rather the whole datable initialization code:
[code]"aoColumns": [
{ "mDataProp": "engine" },
{ "mDataProp": "browser" },
{ "mDataProp": "platform" },
{ "mDataProp": "version" },
{ "mDataProp": "grade" }
][/code]
I have seen the function, but it rather, doesn't bring out the concept clearly...How would I use javascript to define the columns dynamically...table x has the following column definitions [code]{ "mDataProp": "fname" },
{ "mDataProp": "lname" },
{ "mDataProp": "age" },
{ "mDataProp": "dob" },
{ "mDataProp": "grade" }[/code] and another table y have the following:
[code]
{ "mDataProp": "item_code" },
{ "mDataProp": "name" },
{ "mDataProp": "quantity" },
{ "mDataProp": "price" }
[/code]
This discussion has been closed.
Replies
[code]
var my_cols = [ 'fname', 'lname', 'age', 'dob', 'grade' ];
var cols = [];
for ( var i=0, iLen=my_cols.length ; i
[code]<?php if($_SESSION['table_name_id']==0){?>
"aoColumns":[{"mDataProp":"product_id"},
{"mDataProp":"p_name"},
{"mDataProp":"p_price"},
{"mDataProp":"p_quantity"}],
<?php }else if($_SESSION['table_name_id']==1){?>
"aoColumns":[{"mDataProp":"ex_id"},
{"mDataProp":"ex_name"},
{"mDataProp":"ex_amount"},
{"mDataProp":"ex_date"}],
<?php }?>[/code] Though I will try that one as well, as it maximizes on javascript which I was essentially looking for.