Datatables .columnfilter() dynamic lists

Datatables .columnfilter() dynamic lists

zxarrzxarr Posts: 12Questions: 1Answers: 0
edited October 2011 in General
Maybe I missed this somewhere, and I apologize if I did, but when using the .columnfilter, is it possible to build a dynamic list from an already populated column?

If I have a column called timezone, which could be any number of zones, can the dropdown only show the zones that are in the current list?

This was taken from the example I found:

[code]
$('#example').dataTable()
.columnFilter({
aoColumns: [ { type: "select", values: [ (POPULATED FROM COLUMN) ] },
[/code]

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    It looks like Jovan has added this to v1.3.0 of his plug-in. There is an example of it in action here: http://jquery-datatables-column-filter.googlecode.com/svn/trunk/customFilters.html (the "CSS" column - just don't set the "values" property for the object).

    Allan
  • zxarrzxarr Posts: 12Questions: 1Answers: 0
    Thanks for the response.

    I managed to get the drop down menu to appear in the footer, but they're only showing the column headers...

    Am I missing something?

    [code]
    $(document).ready(function() {
    oTable = $('#search').dataTable(
    {
    "bStateSave": true,
    "sAjaxSource": "process_search.php",
    "aoColumns": [
    { "sName": "order", "sTitle": "Order", "sWidth": "5%"} ,
    { "sName": "case", "sTitle": "Case ID", "sWidth": "21%"} ,
    { "sName": "status", "sTitle": "Status", "sWidth": "9%"} ,
    { "sName": "priority","sTitle": "Priority", "sWidth": "12%"} ,
    { "sName": "region", "sTitle": "Region", "sWidth": "5%"} ,
    { "sName": "ruser","sTitle": "User", "sWidth": "10%"} ,
    { "sName": "rdate", "sTitle": "Date", "sWidth": "10%"} ,
    { "sName": "assignee","sTitle": "Assignee", "sWidth": "10%"} ,
    { "sName": "s_search", "sTitle": "Start", "sWidth": "10%"} ,
    { "sName": "e_search","sTitle": "End", "sWidth": "10%"}
    ],
    "sPaginationType": "full_numbers",
    "draggablerows": true,
    "bJQueryUI": true,
    "bSortClasses": false,
    "iDisplayLength": 25,
    "aLengthMenu": [
    [25, 50, 100, -1],
    [25, 50, 100, "All"]
    ]
    })
    .columnFilter({
    aoColumns: [
    null,
    null,
    { type: "select" },
    { type: "select" },
    { type: "select" },
    { type: "select" },
    null,
    { type: "select" },
    null,
    null
    ]
    });
    });
    [/code]
  • zxarrzxarr Posts: 12Questions: 1Answers: 0
    Interesting... One of my columns currently has null data. When I change the column with the null values to the following, all the other drop downs work fine.

    [code]
    .columnFilter({
    aoColumns: [
    null,
    null,
    { type: "select" },
    { type: "select" },
    { type: "select" },
    { type: "text" },
    { type: "Date" },
    { type: "select", values: [ 'name1', 'name2', 'name3', 'name4' ] },
    null,
    null
    ]
    [/code]

    But if I use:
    [code]
    { type: "select" },
    [/code]

    the rest of the filters become blank as well.
  • kwoodkwood Posts: 2Questions: 0Answers: 0
    I am resurrecting this older post because it is very relevant to a problem I am experiencing. The information here is great and exactly what I needed, however, I find that if I am using Datatables server side processing and I don't specify any values for the select filter the filter is not populated with any values at all. Is this a limitation of columnfilter and is there a way around this problem?

    I am rather new to both datatables and columnfilter and to be honest I am still learning jquery so I apologize if the answer to this is obvious. I have to start somewhere and so far I have gotten on very well with your excellent tools!

    I debated opening a new topic with a link to this post, but I decided I would try replying to it first.
  • kwoodkwood Posts: 2Questions: 0Answers: 0
    Actually thinking about this a little bit...

    Yeah only the current page is loaded so how can you possibly gather a list from the entire data set other than doing something in the server side script and populating the select that way.

    I am not sure exactly the route to take on that but I will put some thought in to it.
This discussion has been closed.