1

当数据具有 html 标签时,jqGrid 添加和编辑功能不起作用。如果我给出自动编码,就像“br”“p”标签:真。然后编辑和添加功能工作正常。但它显示为一个字符串。

例如:Hi Ram“html br 标签”你好吗。我的 jqGrid 应该显示为

嗨,拉姆
,你好吗

如果我没有给出 autoencode: true 那么添加和编辑功能不起作用。

我的代码是:

<script type="text/javascript">

$(function () {

    $("#divId").jqGrid({
    colNames:['mailSub','mailBody'],
     colModel: [

                    { name: 'mailSub', index: 'mailSub', sortable: true, align: 'left', width: '150',
                        editable: true, edittype: 'text',search:true,searchoptions:{sopt:['eq']}

                    },
                    { name: 'mailBody', index: 'mailBody', sortable: true, align: 'left', width: '300',
                        editable: true, edittype: 'text',search:true,searchoptions:{sopt:['eq']}

                    } 

              ],

        pager: jQuery('#pager'),
        sortname: 'MessageKey',
        rowNum: 15,
        rowList: [15, 20, 25],
        sortorder: "desc",
        height: 340,
        viewrecords: true,
        rownumbers: true,
        caption: 'Messages',
        width: 660,
        url: "@Url.Content("url given")",
        editurl:"@Url.Content("EditUrl given")",
        datatype: 'json',
        mtype: 'GET'

    })
     jQuery("#divId").jqGrid('navGrid', '#pager', { edit:true, add: true, del: false, search: true, refresh: true },
        { closeOnEscape: true, reloadAfterSubmit: true, closeAfterEdit: true, left: 400, top: 300 },
        { closeOnEscape: true, reloadAfterSubmit: true, closeAfterAdd: true, left: 450, top: 300, width: 520 },
        { closeOnEscape: true, reloadAfterSubmit: true, left: 450, top: 300 },
        {closeAfterSearch:true,closeAfterReset:true,left: 450, top: 300});
});

4

4 回答 4

2

在 jqGrid 中给定的属性为

autoencode: true

以上属性用于对数据进行编码。现在在控制器动作方法中解码现有的编码数据。

 String decodedText = HttpUtility.HtmlDecode(encoded_string);
于 2013-03-16T13:18:08.610 回答
0

试试 autoencode: true,你的网格选项

于 2013-03-16T05:25:52.607 回答
0

设置 colmodel 数据类型 = 'html'

于 2013-10-01T10:25:11.230 回答
0

在 JQGrid 列中添加 html 标记,您希望将相应列的数据类型设置为 html。

数据类型 = 'html'

于 2013-10-24T10:32:10.303 回答