2009-11-02 108 views
1

我試圖使用edittype: 「選擇」,格式: 「選擇」 和editoptions:{值: '1:類型1; 2:2型'}在我colModeljqGrid的下拉菜單中選擇editoptions

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} 
] 

但在json對象中返回的id值不是一個字符串(它沒有引號)。如果我刪除edittype和editoptions id值出現在網格的列,但是當我包括在colMode定義edittype,格式化和editoptions我得到的JavaScript錯誤
(E||"").replace is not a function

失敗看起來像JSON對象

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

該id值沒有引號。

我在其他網格中使用edittype,formatter和editoptions,但是我正在使用的值是一個字符(在json對象中它被引號括起來)並且完美地工作。

我只是猜測問題是沒有引號,但我不確定。有沒有人見過這個?

問候 安德魯

+0

需要一些更多的信息。什麼js文件是拋出你上面列出的錯誤,以及哪一行?並試圖用json對象粘貼回服務器? – 2009-11-02 23:36:59

+0

它停在的文件是jquery-1.3.2.js lin 1067.它看起來像試圖修剪要返回的值。它不會嘗試粘貼回服務器,它假定將edit值中key:value對的值替換爲1的id值,在本例中爲value1。 – 2009-11-03 00:23:59

回答

0

好吧,

我發現problm是在jquery.1.3.2文件的1067行。它是裝飾功能和代碼如下所示:

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

我改成了這樣:

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

,現在它的工作原理。

任何人都可以告訴我,如果這是一個錯誤,或者有其他的東西我可以做的覆蓋ths的功能,而不需要改變jquery文件。

功能覆蓋:放在顯示此問題的任何頁面的頭部。

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

感謝 安德魯

+0

我已經決定,這是一個錯誤,並已覆蓋我的網頁中的功能...請參閱上面的編輯。 – 2009-11-04 06:25:30