mDataProp

mDataProp

TrevorTrevor Posts: 31Questions: 0Answers: 0
edited November 2012 in General
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

Replies

  • allanallan Posts: 63,530Questions: 1Answers: 10,473 Site admin
    Am I correct in saying that it works without the column filter plug-in? Everything you've got there looks fine to me. If it doesn't work without the column filter plug-in please post a link and we'll take a look.

    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
  • TrevorTrevor Posts: 31Questions: 0Answers: 0
    edited November 2012
    I can move things around just fine... but the filters break...

    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
  • allanallan Posts: 63,530Questions: 1Answers: 10,473 Site admin
    Thanks for the link - I wasn't aware of that issue needing feed back from me. I've added it now. it sounds like the server-side processing script that you are using needs to take into account mDataProp.

    This script shows how that might be done: https://github.com/DataTables/DataTables/blob/master/examples/server_side/scripts/objects_jsonp.php

    Allan
  • TrevorTrevor Posts: 31Questions: 0Answers: 0
    edited November 2012
    You're welcome for the link. I found it after you suggested that the plugin may be an issue.

    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!
This discussion has been closed.