2012-07-11 175 views
1

我正在嘗試使用jqgrid內聯編輯功能。但是當內聯編輯器被觸發時,我得到了整個html標籤。 enter image description herejqgrid內聯編輯顯示html標籤

可能是什麼原因?謝謝。

這裏是jqGrid的代碼:

 
$(document).ready(function() { 

'use strict'; 
var grid; 

grid = jQuery("#list2"); 
grid.jqGrid({ 

    editurl: "clientArray", 
    datastr: topicjson, 
    datatype: "jsonstring", 
    height: "auto", 
    loadui: "disable", 
    colNames: [/*"id",*/"Items","nick","url"], 
    colModel: [ 
    //{name: "id",width:1, hidden:true, key:true}, 
    {name: "elementName", width:250, resizable: false, editable: true}, 
    {name: "nick", width:250, resizable: false, editable: true}, 
    {name: "url",width:1,hidden:true} 
    ], 
    treeGrid: true, 
    treeGridModel: "adjacency", 
    caption: "jqGrid Demos", 
    ExpandColumn: "elementName", 
    //autowidth: true, 
    rowNum: 100, 
    //ExpandColClick: true, 
    treeIcons: {leaf:'ui-icon-document-b'}, 
    jsonReader: { 
    repeatitems: false, 
    root: "response" 
    }, 
    cellEdit: true, 
    cellSubmit: "clientArray", 
    onSelectRow: function(id){ 
    if(id && id!==lastSel){ 
    jQuery('#list2').restoreRow(lastSel); 
    lastSel=id; 
    } 
    jQuery('#list2').editRow(id, true); 
    } 

}); 

}); 

+1

圖片很不錯,但代碼更好。 – Musa 2012-07-11 00:25:50

+0

評論是好的,答案是更好的。 – biajee 2012-07-19 20:37:43

+0

:P,如果您更新您的信息*幾個小時*以後通知潛在的回答者,您應該發表評論。 – Musa 2012-07-19 20:45:33

回答

1

事實證明,你可以使用formatCell事件編輯之前更改單元格的內容。返回值是您想要的內容。對於這種特殊情況,treeGrid具有小圖像和單元格中的所有html標籤。當您編輯單元格時,默認情況下所有內容都會顯示爲單元格內容。要修復它,你可以這樣做:

formatCell: function(rowid,cellname,value,iRow,iCol) { 
    return whatever_you_want_to_be; 
    }