asp.net mvc - jQuery Datatables search textbox -


why search textbox not initialize empty? have tried:

table.state.clear(); 

and have tried:

"bstatesave": false, // save datatable state(pagination, sort, etc) in cookie. 

after use filter, redirect view, create new search, come search results textbox has last string used filter.

i'm using mvc5 framework.

enter image description here

enter image description here

var inittable4 = function () {      var table = $('#sample_4');     table.datatable({          "language": {             "aria": {                 "sortascending": ": activate sort column ascending",                 "sortdescending": ": activate sort column descending"             },             "emptytable": "no data available in table",             "info": "showing _start_ _end_ of _total_ records",             "infoempty": "no records found",             "infofiltered": "(filtered1 _max_ total records)",             "lengthmenu": "show _menu_",             "search": "search:",             "zerorecords": "no matching records found",             "paginate": {                 "previous":"prev",                 "next": "next",                 "last": "last",                 "first": "first"             }         },                      "bstatesave": false, // save datatable state(pagination, sort, etc) in cookie.          "lengthmenu": [             [6, 15, 20, -1],             [6, 15, 20, "all"] // change per page values here         ],         // set initial value         "pagelength": 6,         "columndefs": [{  // set default column settings             'orderable': false,             'targets': [0]         }, {             "searchable": false,             "targets": [0]         }],         "order": [             [1, "asc"]         ] // set first column default sort asc     });      var tablewrapper = jquery('#sample_4_wrapper');      table.find('.group-checkable').change(function () {         var set = jquery(this).attr("data-set");         var checked = jquery(this).is(":checked");         jquery(set).each(function () {             if (checked) {                 $(this).prop("checked", true);             } else {                 $(this).prop("checked", false);             }         });     }); } 

i believe table.search('').draw() clear out value of search box, still keep existing column searchers may have.

i implemented [x] clear box on search field follows.

$(document).on('input', '.clearable', function () {     $(this)[tog(this.value)]('x'); }).on('mousemove', '.x', function (e) {      $(this)[tog(     this.offsetwidth - 18 < e.clientx - this.getboundingclientrect().left)]('onx'); }).on('click', '.onx', function () {     $(this).removeclass('x onx').val('');     table.search('').draw(); }); 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -