0

I have jQGrid. Some of columns are edittype:"select".

{label:"Student",name:"student_id",index:"student_id",editable:true,edittype:"select",editoptions:{dataUrl:"../ajax/selects/select_student.php"}},

In my project the number of elements in selects become huge and this lead to usability drawbacks. I want to make selects in add/edit form more intelligent. For this purpose i try to use "chosen" plugin. So, i try this:

beforeShowForm: function() {
       $("#student_id").chosen();
}

In this example "student_id" is the id of select element on add/edit form.

But no effect. Select stay as usual select. Chosen functionality is not added.

How can I have chosen to work on add/edit form for select elements?

  • I personally use [select2](https://select2.github.io/). In any way you should execute `$("#student_id").chosen();` **after** the option will be loaded from `dataUrl`. If you use [free jqGrid](https://github.com/free-jqgrid/jqGrid) then you can use `selectFilled` callback (defined in `editoptions` together with `dataUrl`) or `jqGridSelectFilled` event. See [the answer](http://stackoverflow.com/a/36781867/315935) – Oleg Jun 14 '16 at 13:20
  • You are welcome! If the problem is solved could be solved in the way then I can post the information as the answer. – Oleg Jun 14 '16 at 13:35
  • Thanks for your reply, Oleg. Change code like this editoptions:{dataUrl:"../ajax/selects/select_student.php",selectFilled:function({$("#student_id").chosen();}} But stil no luck. And I must to note, that the selectFilled event is firing. – Denis Orlov Jun 14 '16 at 13:37
  • And one more thing I use jqGrid 5.0.0 – Denis Orlov Jun 14 '16 at 13:43
  • There are two forks with version higher as 4.7: [free jqGrid](https://github.com/free-jqgrid/jqGrid), which I develop and provide for free under MIT/GPLv2-licenses, and **commercial** Guriddo jqGrid JS available [here](https://github.com/tonytomov/jqGrid) or [here](http://www.trirand.com/blog/?page_id=6), which **can't be used for free**. You can find the prices and the license [here](http://guriddo.net/?page_id=103334). Do you paid for jqGrid 5.0.0 (Guriddo jqGrid JS)? In the case you can report the problem to [Guriddo forum](http://guriddo.net/?forum=guriddo-js) – Oleg Jun 14 '16 at 13:53
  • As I remember, I get my version from GitHub. – Denis Orlov Jun 14 '16 at 13:56
  • There are a lot of open source project on GitHub. Somewhere you can use for free, but another one could be expensive. Some code can be used in modified, but another project it can be modified only by the owner. In UPDATED part of [the answer](http://stackoverflow.com/a/4439755/315935) you can find some links with information about the usage of jqGrid (free or not free). If you use Guriddo jqGrid without payment then you can get some day the letter from the lower with requirement to pay 10 time higher sum as official prices of Guriddo. It's your choice. – Oleg Jun 14 '16 at 14:41
  • that is good. I've read license policy on gurrido.net. And I'm glad that you make me think about this question. But this is another story. Anyway, thanks. But there is no answer yet – Denis Orlov Jun 14 '16 at 15:10
  • I wrote you in my first comment, that I suppose that you execute `$("#student_id").chosen();` in `beforeShowForm` which will be executed after *empty* ``. In free jqGrid you can *move* `$("#student_id").chosen();` to `selectFilled` callback. Then `chosen` should work. – Oleg Jun 14 '16 at 15:27
  • Try it already. It not work. Ok. I'll try to resolve this by myself and give feedback. – Denis Orlov Jun 14 '16 at 15:37
  • What is "not work"? Will be `chosen` not created? Is it empty? Do you have overlaps problems? Do you have zIndex problems?... You should post the code which you used or better to prepare the demo. It should work or you could have some common problems in the usage of `chosen`. I wrote that I personally use select2. – Oleg Jun 14 '16 at 15:44
  • I'd recommend you to use [select2](https://select2.github.io/) because integration of `chosen` can take much more time and select2 seems to be more powerful and more flexible. – Oleg Jun 14 '16 at 18:46
  • Thanks, Oleg, Playing with chosen yesterday for about 4 hours do not bring expected results. Using "select2" do all what I need. But there is another question: in editform of jqGrid how to select rigth value of select2?(By default there is no selection when editing) – Denis Orlov Jun 15 '16 at 10:04
  • Hi Denis. Do you means that editing value will be not selected in `select2` in your code? You should append your code and the response returned from `dataUrl` to the text of your question. I suppose that you used `select2` in incorrect way. – Oleg Jun 16 '16 at 05:37

0 Answers0