Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Jquery网格列中动态启用HTML标记_Javascript_Jquery_Jqgrid_Struts2 Jquery Grid - Fatal编程技术网

Javascript 如何在Jquery网格列中动态启用HTML标记

Javascript 如何在Jquery网格列中动态启用HTML标记,javascript,jquery,jqgrid,struts2-jquery-grid,Javascript,Jquery,Jqgrid,Struts2 Jquery Grid,我需要在Jquery网格列中动态启用HTML标记 我怎样才能做到这一点 我的代码是 jQuery("#jqgrid").jqGrid({ data: $scope.jqgrid_data, datatype: "local", height: 'auto', sortable: false, width: '900', colModel: $scope.ColDefinations,

我需要在Jquery网格列中动态启用HTML标记

我怎样才能做到这一点

我的代码是

     jQuery("#jqgrid").jqGrid({
        data: $scope.jqgrid_data,
        datatype: "local",
        height: 'auto',
        sortable: false,
        width: '900',
        colModel: $scope.ColDefinations,
        viewsortcols: [true, 'vertical', true],
        rowNum: $scope.pageSize,
        pager: '#pager_jqgrid',
        sortname: 'Student Name',
        toolbarfilter: true,
        viewrecords: true,
        sortorder: "asc",
        multiselect: false,
        autowidth: false,
        autoencode: true,
        gridview: true,
        rownumbers: true,
        shrinkToFit: false,
        forceFit: true,
        loadonce: false,
        pgbuttons: false,
  });
像这样绑定html

    jQuery(".jqg-second-row-header th:eq(" + i + ")").text(titletext[0] + "<span> hai</span>");
jQuery(“.jqg第二行标题th:eq(“+i+”)).text(titletext[0]+“hai”);
谁能帮助我,我错在哪里


提前感谢使用colModel时,您可以使用label选项在列标题中插入任何html标记。如上所述

你可以

...
colModel : [
    { label : "Mynanme <span> hai</span> ", name: "field1",....},
    ...
],
...
。。。
colModel:[
{标签:“Mynanme hai”,名称:“field1”…},
...
],
...
要动态设置标签,请使用setLabel方法

$(“#jqGrid”).jqGrid(“setLabel”、“field1”、“Myname hai”);
请参见其他参数以更改视觉显示

$("#jqGrid").jqGrid("setLabel", "field1", "Myname <span> hai</span>");