1

I'm kinda stuck with the searchoptions property in jqgrid. When I hit the search icon in the grid and traverse to the field with the 'dropdown', I get to see the below error in firefox and IE8

FF : TypeError: g is undefined in jquery.jqGrid.min.js (line 239)

IE : Message: 'postData' is null or not an object Line: 238

Below is the code snippet,

  {name:'City', index:'City', width:80, align:'right', 
   editable: true,search:true,edittype: 'select',stype:'select',
   searchoptions: {
     ajaxSelectOptions: {type: "GET",datatype:"text"},
     dataUrl:  '/TESTAPP/Test',          
     dataEvents: [
             {  type: 'change',
                fn: function(e) {
                  alert(this.value)
              }
             } 
          ]}

I don't even see the request hitting the server which is very strange.

P.S : The same works fine with the editoptions

Version:

jqGrid: 4.4.5

jquery: 1.9.1

Thanks for any help!

Oleg
  • 220,925
  • 34
  • 403
  • 798
Faz
  • 534
  • 1
  • 9
  • 27
  • Could you repeat the same test with `jquery.jqGrid.src.js` instead of `jquery.jqGrid.min.js`? The line number in `jquery.jqGrid.min.js` hold almost no information. By the way `ajaxSelectOptions` is [option of jqGrid](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options) and not not a property of `searchoptions`. You should use `dataType` instead of `datatype` inside of `ajaxSelectOptions`, but the standard type `"html" for `ajaxSelectOptions` need be typically not changed to `"text"``. – Oleg Apr 19 '13 at 12:38
  • Yep initially I tried without setting the ajaxSelectOptions property, but then wanted to give it a try. Anyway, i will have it removed and try it with the src.js and let you know. – Faz Apr 19 '13 at 12:45
  • There you go, this is the error that I get with the src.js **TypeError: ajaxso is undefined** in _jquery.jqGrid.src.js (line 5832)_ – Faz Apr 19 '13 at 12:50
  • Could you try to start the test in Developer Tools of IE/Chrome or in Firebug and set breakpoint of the line 5832. It's important to know from which place the method `createEl` are called. The line of the caller is interesting. You can see the values of the parameters. You don't wrote which type of searching you use (toolbar searching or advanced searching), so the caller of the method is unclear. – Oleg Apr 19 '13 at 12:57
  • oh my bad, its the advanced searching. Yeppie!! I got this issue resolved... its indeed with the **ajaxSelectOptions** option. Looks like the searching needs the options to be set to enable the select option to work. I just had the property moved to the jqGrid and it worked like a Charm!!! I know its bad to ask another question here, but if possible can you please help me out with [link](http://stackoverflow.com/q/16050565/2288848) Needed help badly on this.. – Faz Apr 19 '13 at 13:00

2 Answers2

5

ajaxSelectOptions should be included jqGrid for the single serach and advanced serach to enable the 'select' option for any column in colModel.

 var grid = $("#list");
 grid.jqGrid({
     ajaxSelectOptions: {type: "GET"},
     colModel: [ 
            {name:'City', index:'City', width:80, align:'right', 
             editable:  true,
             search:true, 
             edittype: 'select',
             stype:'select',
             searchoptions: {
                 dataUrl: '/TESTAPP/Test',
                 buildSelect: function(resp) {
                     var sel= '<select>';
                     var obj = $.parseJSON(resp);
                     $.each(obj, function() {
                         sel += '<option value="'+this['value']+ '">'+this['label'] + "</option>"; // label and value are returned from Java layer
                     });
                     sel += '</select>';
                     return sel;
                 },          
                 dataEvents: [{  
                     type: 'change',
                     fn: function(e) {
                         alert(this.value)
                     }
                 }]
             }
      }]
 });
Brant Olsen
  • 5,628
  • 5
  • 36
  • 53
Faz
  • 534
  • 1
  • 9
  • 27
1

I had the same problem in Chrome. I was getting following error

Uncaught TypeError: Cannot read property 'postData' of undefined jquery.jqGrid.min.js:239

Adding

ajaxSelectOptions: {type: "GET"} 

fixed it. Thanks

Rashmi
  • 229
  • 2
  • 9