1
votes

I am trying to use the edittype:"select", formatter:"select" and editoptions:{values:'1:Type1;2:Type2'} in my colModel

colModel : [  
         {name:'pk', index:'pk', width:20, sortable:true, jsonmap:'pk',  
          sorttype:'integer'},
         {name:'id', index:'id', align:'left', jsonmap:'fields.id',  
          sortable:true, editable:true, edittype:'select', formatter:'select',  
          editoptions:{value:'1:value1;2:value2;3:value3'},  
         {name:'type', index:'type', width:100,align:'center',  
          jsonmap:'fields.type',  sortable:true,editable:true}  
]

but the value for id returned in the json object is not a string (it doesn't have quotes around it). If I remove the edittype and editoptions the id value appears in the column of the grid but when I include the edittype, formatter and editoptions in the colMode definition I get the javascript error
(E||"").replace is not a function

The json object that fails looks like

 { "pk": 120  
   "model": "myModel"  
   "fields": {  
       "id": 1,
       "type": "aType"
   }
  }

The id value has no quotes.

I am using the edittype, formatter and editoptions in other grids but the value I am macthing against is a character (in the json object it is surrounded by quotes) and it works perfectly.

I am only guessing that the problem is with the unquoted number but I am not sure. Has anyone seen this before?

Regards Andrew

1
need a little more info. What js file is throwing the error you listed above, and which line? And is the row trying to paste back to the server with a json object?Bobby Borszich
the file that it stops on is jquery-1.3.2.js lin 1067. It looks like it is trying to trim the value to return. It is not trying to paste back to the server it is suppose to be replacing the id value of 1 with value from the key:value pair in the editoptions, which in this case is value1.Andrew Gee

1 Answers

0
votes

Ok,

I found that the problm is on line 1067 of the jquery.1.3.2 file. It is the trim function and the code looks like this:

trim:function(text) {  
  return (text||"").replace(/^\s+|\s+$/g, "")
}

I changed it to this:

trim:function(E) {  
  return (text.toString()||"").replace(/^\s+|\s+$/g, "")
}

and now it works.

Can anyone tellme if this is a bug or is there something else I can do to overide ths function without changing the jquery file.

Function Override: Placed in the head of any page that shows this problem.

$.extend({
    trim:function(E) {  
      return (text.toString()||"").replace(/^\s+|\s+$/g, "")
    }
});

Thanks Andrew