mDataProp
mDataProp
I'm apparently misunderstanding the use of mDataProp and how to actually map the fields. What I want to be able to do is to simply add a new field to the getdata.php file and be able to simply add the mapping in the initialization script.
Here's a small example of how I've mapped the fields:
[code]
{"mDataProp": "TERM"}, // TERM
{"mDataProp": "TERM_START"}, // TERM_START
{"mDataProp": "TERM_END"}, // TERM_END
{"mDataProp": "CKT_SOURCE", "bVisible": false} // CKT_SOURCE
[/code]
Here is my .columnfilter code:
[code]
{ type: "select",
values: [ <? echo generateSearchOptions("", "CIRCUIT_DATA", "TERM"); ?> ] }, // TERM
{ }, // TERM_START
{ }, // TERM_END
{ } // CKT_SOURCE
[/code]
My json is returning as (this is just a snippet):
[code]
{
"sEcho": 6,
"iTotalRecords": 21506,
"iTotalDisplayRecords": 21506,
"aaData": [{
"TERM": "TERM",
"TERM_START": "TERM_START",
"TERM_END": "TERM_END",
"CKT_SOURCE": "CKT_SOURCE"
}]
}
[/code]
In reading I saw that I have to take my mapping into account some how in the server side script. I wasn't able to find anything on HOW to do this.
My goal is to be able to simply add/remove/edit the table headers, the mDataProp fields, and .columnFilter code without having to wrangle with the server-side data script.
Currently, if I want to move a column from the end of the list to the beginning and only edit it in the initialization, the filters break. As soon as I go to the server-side script and update the order there, everything works fine again.
Any help is appreciated.
Thanks,
Trevor
Here's a small example of how I've mapped the fields:
[code]
{"mDataProp": "TERM"}, // TERM
{"mDataProp": "TERM_START"}, // TERM_START
{"mDataProp": "TERM_END"}, // TERM_END
{"mDataProp": "CKT_SOURCE", "bVisible": false} // CKT_SOURCE
[/code]
Here is my .columnfilter code:
[code]
{ type: "select",
values: [ <? echo generateSearchOptions("", "CIRCUIT_DATA", "TERM"); ?> ] }, // TERM
{ }, // TERM_START
{ }, // TERM_END
{ } // CKT_SOURCE
[/code]
My json is returning as (this is just a snippet):
[code]
{
"sEcho": 6,
"iTotalRecords": 21506,
"iTotalDisplayRecords": 21506,
"aaData": [{
"TERM": "TERM",
"TERM_START": "TERM_START",
"TERM_END": "TERM_END",
"CKT_SOURCE": "CKT_SOURCE"
}]
}
[/code]
In reading I saw that I have to take my mapping into account some how in the server side script. I wasn't able to find anything on HOW to do this.
My goal is to be able to simply add/remove/edit the table headers, the mDataProp fields, and .columnFilter code without having to wrangle with the server-side data script.
Currently, if I want to move a column from the end of the list to the beginning and only edit it in the initialization, the filters break. As soon as I go to the server-side script and update the order there, everything works fine again.
Any help is appreciated.
Thanks,
Trevor
This discussion has been closed.
Replies
If it is breaking when the column filter plug-in is used, I'd suggest opening an issue against that plug-in - it is a third party plug-in and I don't know much about it I'm afraid.
Allan
columnFilter plugin has a thread on this problem and points at something in DataTables as the likely cause. That thread is here: http://code.google.com/p/jquery-datatables-column-filter/issues/detail?id=56&q=mdataprop
My installation is at:
http://www.greenwavemediagroup.com/regex/Vendor/sandbox/circuitreport/index_grooming.php
This script shows how that might be done: https://github.com/DataTables/DataTables/blob/master/examples/server_side/scripts/objects_jsonp.php
Allan
I believe your script link is just what the doctor ordered for getting mDataProp to allow me to edit the code more efficiently. I only found posts alluding to accounting for it server side but nothing solid.
Thank you!