0

I am using jQuery DataTables and the Column Filter plugin.

One of the options in the column filter plugin is to display a dropdown to filter a column's data on.

$("#logTable").dataTable({
    "aaSorting": [[ 1, "desc" ]],
    "bJQueryUI": true,
    "iDisplayLength": 50,
    "aLengthMenu": [10, 25, 50, 100],
    "sPaginationType": "full_numbers",
    "aoColumns": [ 
        { "bSortable": true },
        { "bSortable": true },
        { "bSortable": true },
    ]
}).columnFilter({
    sPlaceHolder: "head:after",
    aoColumns: [ 
        { type: "select", values: ['admin', 'input'] },   /*This creates the dropdown) */
        { type: "text" },
        { type: "text" },
    ]
});

I'm trying to have that list updated dynamically from the page the data table is on.

I've created a hidden element and gave it the value of the possible options

<input type="hidden" id="dValues" value="admin,input">

Then changed my script to

var dValues = $("#dValues").(val);    
$("#logTable").dataTable({
    "aaSorting": [[ 1, "desc" ]],
    "bJQueryUI": true,
    "iDisplayLength": 50,
    "aLengthMenu": [10, 25, 50, 100],
    "sPaginationType": "full_numbers",
    "aoColumns": [ 
        { "bSortable": true },
        { "bSortable": true },
        { "bSortable": true },
    ]
}).columnFilter({
    sPlaceHolder: "head:after",
    aoColumns: [ 
        { type: "select", values: [dValues] },   /*No luck */
        { type: "text" },
        { type: "text" },
    ]
});

I've also tried

<input type="hidden" id="dValues" value="admin,input">

with no luck. If I remove the [] from { type: "select", values: [dValues] } I get each letter of the contents of dValues as an option so I think it's possible to get what I want I just can't figure out how to get each item in properly.

1 Answer 1

1

I was using version DatTables 1.9. Version 1.10 seems to have added what I needed. http://www.datatables.net/examples/api/multi_filter_select.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.