4

I am using jqgrid version 4.4.4 and right now I am facing one problem related to toolbar searching. As I mention in heading, I want remove search box of toolbar search from any column "dynamically" during or after rendering a grid. I google it but I didn't found any relevant solution on my this problem. I used selColProp property like this

$('#<gridId>').jqGrid('setColProp', 'LotNo', {
    search: false
});

and mentioned in loadcomplete function due to some logical reason. If anyone knows how to do this, kindly share your valuable ideas.

UPDATED: Now I am using free jqgrid version 4.9.2 and this functionality also not happening on it.

Rahul More
  • 615
  • 3
  • 13
  • 41

1 Answers1

2

Searching toolbar will be created once. It includes all searchable columns in the searching toolbar. If you need to change the search property dynamically then you have to recreate the searching toolbar after changing the value of search property. You need just call destroyFilterToolbar to remove the searching toolbar and then call filterToolbar once more time.

Alternatively you can consider just to hide the searching field after setting the search property to false. The corresponding code could be something like

$("#gs_LotNo").closest(".ui-search-table").hide();

The string gs_LotNo is the id of the input field of the LotNo column. and using $("#gs_LotNo").closest(".ui-search-table") you get the outer table which contains optional searching menu and x button. You can consider to make the content of the field empty ($("#gs_LotNo").val("")) before hiding to be sure that the current value in the input field will not be used in filters.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • I removed my code of `setColProp` and used your code but nothing happen. I have pasted this code into my `loadComplete` function. – Rahul More Oct 09 '15 at 11:25
  • You should **not remove** setting `search: false`. If you need change the value of `search: false` then you should do this **and** change the searching toolbar *after* that (by recreating the toolbar or by hiding the field). You write about the usage of `setColProp` in `loadComplete`. Why? I can't follow you in the case. What you need to do and how frequently? The `loadComplete` will be called after applying the filter, after sorting and paging an so on. What is your scenario? How you fill the grid? **When** you change `search` property of `LotNo`? Which `datatype` and `loadonce` you use? – Oleg Oct 09 '15 at 11:33
  • instead of calling this code into `loadComplete`, I called your code in `gridComplete` and wallaaaa.. It worked. Thank you sir. – Rahul More Oct 09 '15 at 12:08
  • @Rahul: You are welcome! The calling such code in `gridComplete` seems me wrong too. I recommend you to post more full code which should what you do. It's important to know *how you fill the grid with data*, which `datatype` and `loadonce` you use, when later you decide to change the properties. If you load the information from the server and use `datatype: "json"` than you can change column property in `beforeProcessing` callback for example. – Oleg Oct 09 '15 at 12:16
  • Yes.. you are absolutely right, my `datatype: json` and I didn't used property `loadonce`. – Rahul More Oct 09 '15 at 12:23
  • @Rahul: I recommend you to read [the old answer](http://stackoverflow.com/a/15439276/315935) about the difference of `loadComplete` and `gridComplete` and [the answer](http://stackoverflow.com/a/17410568/315935) and [this one](http://stackoverflow.com/a/19427444/315935) as examples of changing `colModel` based on server response inside of `beforeProcessing` – Oleg Oct 09 '15 at 12:28