19857

jqGrid Advanced Search dialog - column which has dropdown selection

Question:

I have a jqGrid 4.3.1 with Advanced filter. some of the columns which are boolean types like Yes/No types, I show a dropdown when the column type is selected when a new advanced filter row is created. E.g. Say column 2 is IsActive (Boolean) type and when this is selected I shown a drop down instead of the textbox. The code which overrides the jqGrid advanced filter is as follows:

var cols = grid.jqGrid("getGridParam", "colModel"); for (var i = 0; i < cols.length; i++) { if (cols[i].stype && cols[i].stype == "select" && cols[i].searchoptions && cols[i].searchoptions.buildSelect && $.isFunction(cols[i].searchoptions.buildSelect) && !cols[i].searchoptions.dataUrl && !cols[i].searchoptions.value) { cols[i].searchoptions.value = cols[i].searchoptions.buildSelect(null); }

This code used to work fine in 4.3 version (one version before 4.3.1) Don't know what is causing the problem but now my dropdowns appear blank. Any help appreciated!

Answer1:

You don't posted the code of buildSelect which you use, so it's difficult to say why the code fail. What I don't understand mostly is why you has so complex code at all. If you know that the column IsActive has type Boolean and you want display it in the Advance Searching dialog as drop-down having "Yes" and "No" values and display it in grid and during editing as checkbox you can do the following:

<pre class="lang-js prettyprint-override">{ name: "IsActive", template: myCheckboxTemplate }

where mytemplateCheckbox you define like

<pre class="lang-js prettyprint-override">var myCheckboxTemplate = { formatter: "checkbox", align: "center", width: 20, edittype: "checkbox", editoptions: { value: "1:0" }, stype: "select", searchoptions: { sopt: ["eq", "ne"], value: "1:Yes;0:No" } };

The described approach I use permanently and it works very well. The only difference from the code above is that I use <a href="http://www.trirand.com/blog/?page_id=393/feature-request/make-disabled-checkbox-of-the-checkbox-formatter-clickable/#p25668" rel="nofollow">"clickableCheckbox"</a> formatter instead of "checkbox". If you want you can download it from <a href="https://github.com/OlegKi/jqGrid-plugins" rel="nofollow">here</a>.

Recommend

  • Get column name of selected row jqGrid
  • Problem with deleting jqGrid row data -client side-
  • I want to get the edit dialog on click of a link..I have attached the code
  • jqGrid: Combining sortableRows and gridDnD (Duplicate Rows)
  • free jqGrid search parameter disappearing in filterToolbar
  • JqGrid Select Box in a cell
  • Custom Animation Object for Transition in Android?
  • How to count spring coil turns?
  • Why String.ToString()? [duplicate]
  • SiteMesh: Changing the content-type of the response
  • Referring to individual variables in … with dplyr quos
  • JQgrid : Change entire row's font color if one column is filled
  • How to start server for Selenium grid Java Maven setup
  • Refresh other frame, from another frame. Jquery
  • Allocating a 2D contiguous array within a function
  • Sort an arraylist of objects in java
  • How to save dynamically created textboxes and their values
  • Dynamically load css stylesheet and wait for it to load
  • How to add a focus style to an editable ComboBox in WPF
  • Email format validation in mvc3 view
  • AES padding and writing the ciphertext to a disk file
  • javascript inside java/jsp code
  • retrieve vertices with no linked edge in arangodb
  • How to delete a row from a dynamic generate table using jquery?
  • Benchmarking RAM performance - UWP and C#
  • Acquiring multiple attributes from .xml file in c#
  • using HTMLImports.whenReady not working in chrome
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Change div Background jquery
  • Authorize attributes not working in MVC 4
  • apache spark aggregate function using min value
  • How can I remove ASP.NET Designer.cs files?
  • EntityFramework adding new object to nested object collection
  • Sorting a 2D array using the second column C++
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize