Individual column searching (select inputs)

Individual column searching (select inputs)

DorababuDorababu Posts: 17Questions: 2Answers: 0

Hello all I modified the code which was here https://www.datatables.net/examples/api/multi_filter_select.html to add the drop downs next to header which is here

https://jsfiddle.net/6kjm02eh/

But when I click on the drop down it is sorting, can it be stopped? Also I am using MVC code to bind the grid and have the required code. But with Individual column searching how to filter and show the filtered data

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,277Questions: 26Answers: 4,766

    Create two headers; one for sorting and one for the search inputs. Use orderCellsTop to move the sorting to the top header row. Similar to this example. You can find lots of threads regarding this on the forum if you need more examples.

    Kevin

  • DorababuDorababu Posts: 17Questions: 2Answers: 0

    Thanks Kevin, can it be shown like drop downs instead of text boxes and fill the values

  • kthorngrenkthorngren Posts: 20,277Questions: 26Answers: 4,766
    Answer ✓

    Yes. There are lots of examples on the forum like this example.

    Kevin

  • DorababuDorababu Posts: 17Questions: 2Answers: 0

    Thanks how about filtering on the server side? How can I do that for search we are doing this way.

    string search = Request.Form.GetValues("search[value]")[0];

    Is there a similar way for this

  • DorababuDorababu Posts: 17Questions: 2Answers: 0
    edited January 2022

    I am able to do this way but I am getting some special character

    Request.Form.GetValues("columns[1][search][value]").FirstOrDefault()

    Can we remove special characters

    ^Barge/pontoon/floating dock$

  • DorababuDorababu Posts: 17Questions: 2Answers: 0

    OK got it I fixed here I removed the special characters

    column
    .search(val ? '' + val + '' : '', true, false)
    .draw();

  • DorababuDorababu Posts: 17Questions: 2Answers: 0

    Hi one more question when I turn off this property the drop down filter is not working

    "filter": false,

  • DorababuDorababu Posts: 17Questions: 2Answers: 0

    Also it is possible to have a date picker when there is a date column instead of select. Can it be customized like that

  • kthorngrenkthorngren Posts: 20,277Questions: 26Answers: 4,766

    Can we remove special characters

    The example uses .search( val ? '^'+val+'$' : '', true, false ). The column().search() docs explain the other parameters, ie, true, false. The ^ and $ are regular expression tokens. As you found you can remove those. Plus you can remove the two parameters if you want.

    when I turn off this property the drop down filter is not working

    That is correct. The searching option turns off searching. You used filter which is the old (Datatables 1.9 version) of the option. If you are trying to remove the default global search input then use the dom option to remove it but leave searching turned on.

    Also it is possible to have a date picker when there is a date column instead of select. Can it be customized like that

    Yes. You can add a datetime picker. Datatables has a datetime picker extension or you can use your own. The example I provided uses a classname to determine which columns to apply the select input. You can do something similar to apply the datetime picker to the selected columns.

    Kevin

Sign In or Register to comment.