How to update the default search to equals instead of contains

How to update the default search to equals instead of contains

vikaspandey.dotnetvikaspandey.dotnet Posts: 2Questions: 1Answers: 0
edited December 2016 in Free community support

I am dynamically creating Data table where my columnname and Rowdata both are coming from server side using ajax call. Here is the code.

               $.ajax({
                type: "POST",
                url: "Default.aspx/ConvertDatadttoString",
                data: '{"appName":"' + appName + '"}',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function OnSuccess(response) {
                    dataObject = eval(response.d);

                   var oTable = $('#JDatadt').dataTable({
                        "order": [],
                        "dom": "Bfrtip",
                        "buttons": ["csv", "excel", "pdf"],
                        "columnDefs": [{ "className": "dt-center", "orderable": false, "width": 20 }],
                        "bInfo": false,
                        "paging": true,
                        "processing": true,
                        "columns": dataObject[0].columns,
                        "data": dataObject[0].Griddata
                    });

                },
                failure: function Onfailure(response) {
                }
            });

Now I have got an issue wherein I need to filter my grid for Active and InActive data which is available in one of my column. Now in this situation my search is not working. I need to get generic solution which should not be hardcoded.
How to do it ? Thanks

Answers

  • allanallan Posts: 63,208Questions: 1Answers: 10,415 Site admin

    You'd need to use a regular expression. The default search always just does a 'contains'.

    I'm going to change that in the next major release so that it will do a 'starts with' search, but that is some time off.

    Allan

  • vikaspandey.dotnetvikaspandey.dotnet Posts: 2Questions: 1Answers: 0

    Could you please guide me where to add regular expression. I am a bit confused as my columns and rows are getting generated dynamically.
    Please suggest. Thanks

  • allanallan Posts: 63,208Questions: 1Answers: 10,415 Site admin

    How are you doing the search. Are you using the search() method? As I noted, you can't use the default search (i.e. the default input box) since it always does a contains.

    Allan

This discussion has been closed.