Issues when searching a specific column

Issues when searching a specific column

ArielSAdamsNASAArielSAdamsNASA Posts: 105Questions: 15Answers: 0

Link to test case: http://live.datatables.net/jahazase/21/edit
Description of problem: I know how to search for a specific using something along the lines of dt_all.columns(20).search( '{{ user_name }}' ).draw();. This code will search user_name, but when the user refreshes the page. Another issue is that the text, user_name, is not in the search box. When using dt_all.search( '{{ user_name }}' ).draw(); these issues are not present. My question is how can I search user_name for column 20, without these issues? Or is it possible to use dt_all.search( '{{ user_name }}' ).draw(); but exclude the search of column 27 such as a NOT statement?

My website works as so:
The main page, say https://main, lists the top authors as a link. This link will take the user_name of the author and input the variable to a datatable on another page, say https://example. It uses django to do so. So, user_name is not used in the searchbox if the variable is not passed by either clicking the link on the main page or going to a subpage such as https://example/10.

Answers

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    This is presumably related specifically to state saving?

    Another issue is that the text, user_name, is not in the search box

    DataTables doesn't control the column search inputs - they control it! It knows nothing about them, so it can't fill them in. The global search however is controlled by DataTables which is why it just works.

    Have a look at the first comment here which discussed how it could operate with state saving (that example is for select inputs, but could operate with input as well.

    but exclude the search of column 27 such as a NOT statement?

    You can exclude a column from the global search by using the columns.searchable option.

    Allan

Sign In or Register to comment.