我需要动态启用 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,
});
像这样绑定(bind)html
jQuery(".jqg-second-row-header th:eq(" + i + ")").text(titletext[0] + "<span> hai</span>");
谁能帮帮我,我哪里错了
提前致谢
最佳答案
使用 colModel 时,您可以使用 label 选项在列标题中插入任何 html 标签。如上所述here
你可以
...
colModel : [
{ label : "Mynanme <span> hai</span> ", name: "field1",....},
...
],
...
要动态设置标签,请使用setLabel方法described here
$("#jqGrid").jqGrid("setLabel", "field1", "Myname <span> hai</span>");
查看其他参数来更改视觉呈现。
关于javascript - 如何动态启用 Jquery 网格列中的 HTML 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45208416/