Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You problem can be very easy solved with respect of <code>postData</code> parameter including functions and <code>trigger('reloadGrid')</code>. I try explain the idea more detailed.</p> <p>Let us use <code>mtype: "GET"</code>. The only thing which standard search/filter box do after displaying the interface is appending of some additional parameters to the url, sending to server and reloading the grid data. If you have your own interface for searching/filtering (some select controls or checkboxes, for example) you should just append your url yourself and reload the grid with respect of <code>trigger('reloadGrid')</code>. For resetting of the information in the grid you can choose any way which you prefer. For example, you can include in the select controls which you have an option like "no filtering".</p> <p>To be more exact your code should looks like the code from the answer <a href="https://stackoverflow.com/questions/2839721/how-to-reload-jqgrid-in-asp-net-mvc-when-i-change-dropdownlist/2842199#2842199">how to reload jqgrid in asp.net mvc when i change dropdownlist</a>:</p> <pre><code>var myGrid = jQuery("#list").jqGrid({ url: gridDataUrl, postData: { StateId: function() { return jQuery("#StateId option:selected").val(); }, CityId: function() { return jQuery("#CityId option:selected").val(); }, hospname: function() { return jQuery("#HospitalName").val(); } } // ... }); // var myReload = function() { myGrid.trigger('reloadGrid'); }; var keyupHandler = function (e,refreshFunction,obj) { var keyCode = e.keyCode || e.which; if (keyCode === 33 /*page up*/|| keyCode === 34 /*page down*/|| keyCode === 35 /*end*/|| keyCode === 36 /*home*/|| keyCode === 38 /*up arrow*/|| keyCode === 40 /*down arrow*/) { if (typeof refreshFunction === "function") { refreshFunction(obj); } } }; // ... $("#StateId").change(myReload).keyup(function (e) { keyupHandler(e,myReload,this); }); $("#CityId").change(myReload).keyup(function (e) { keyupHandler(e,myReload,this); }); </code></pre> <p>If user change selected option in select box with <code>id=StateId</code> or another select box with <code>id=CityId</code> (with mouse or keyboard), the function <code>myReload</code> will be called, which just force reloading of data in jqGrid. During corresponding <code>$.ajax</code> request, which jqGrid do for us, the value from <code>postData</code> parameter will be forwarded to <code>$.ajax</code> as <code>data</code> parameter. If some from properties of <code>data</code> are functions, these function will be called by <code>$.ajax</code>. So the actual data from select boxes will be loaded and all the data will be appended to the data sent to the server. You need only implement reading of this parameters in your server part.</p> <p>So the data from the <code>postData</code> parameter will be appended to the url (symbols '?' and '&amp;' will be added automatically and all special symbols like blanks will be also encoded as usual). The advantages of the usage of <code>postData</code> is:</p> <ol> <li><strong>usage of functions</strong> inside <code>postData</code> parameter allows you to load <strong>actual</strong> values from all used controls to the moment of reloading;</li> <li>Your code stay have very clear structure.</li> <li>All works fine not only with HTTP GET requests, but with HTTP POST also;</li> </ol> <p>If you use some "no filtering" or "all" entries in the select box <code>StateId</code>, you can modify the function which calculate the value of <code>StateId</code> parameter which should appended to the server url from </p> <pre><code>StateId: function() { return jQuery("#StateId option:selected").val(); } </code></pre> <p>to something like following:</p> <pre><code>StateId: function() { var val = jQuery("#StateId option:selected").val(); return val === "all"? "": val; } </code></pre> <p>On the server side you should makes no filtering for <code>StateId</code> if you receive an empty value as a parameter.</p> <p>Optionally you can use <code>myGrid.setCaption('A text');</code> to change a grid title. This allow user to see more clear, that the data in grid are filtered with some criteria.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload