Filtering specific value of specific column

Filtering specific value of specific column

javismilesjavismiles Posts: 30Questions: 2Answers: 0

Hi,
I'm trying to use this
"aoSearchCols": [
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,{ "sSearch": "peter" },,null,null,null,null,null,null,null,null,null,null],

to filter column 21 of a table,

it's not working yet but anyway is there an easy way?
so that I don't have to list the 31 columns to just filter column 21 of the table?

thank you

Replies

  • kthorngrenkthorngren Posts: 1,565Questions: 18Answers: 322

    If you are using a current version (1.10) of Datatables then you will want to use the current for of the options, for example: searchCols.

    According to the doc the array needs to be the same length as the number of columns.

    If you don't want to define 20 null columns then maybe you can use columns().search(). You can place it within initComplete to execute once the table has initialized.

    Kevin

  • javismilesjavismiles Posts: 30Questions: 2Answers: 0

    mmm, I see, what about,
    is it possible to do a search based on an SQL query?

    like init the table in connection with a specific SQL query like
    "SELECT * from table where org='whatever'

    thank you again

  • kthorngrenkthorngren Posts: 1,565Questions: 18Answers: 322

    Not sure what your config is but one option is to use the data parameter to send data you want to search to your server. Your server code would need to parse the parameters sent to perform the sql query.

    You can read about the jQuery ajax parameters here:
    http://api.jquery.com/jquery.ajax/

    Kevin

Sign In or Register to comment.