我在我的项目中使用jsGrid,现在我被困在这里隐藏一个在代码中使用但不应在页面中显示的列。
我使用的网格是:jsGrid
我尝试接受输入控件hidden
,但仍然不起作用。
以下代码定义了我为AccountID
采用隐藏字段的网格列。但是,它不起作用。
代码:
fields: [
{ name: "Account", width: 150, align: "center" },
{ name: "Name", type: "text" },
{ name: "AccountID", type: "hidden", width: 0}
]
答案 0 :(得分:14)
由于v1.3 jsGrid字段有一个选项visible
http://js-grid.com/docs/#fields
如果您需要在运行时隐藏(或显示)某个字段,可以按以下方式完成:
$("#grid").jsGrid("fieldOption", "ClientName", "visible", false);
答案 1 :(得分:6)
请尝试以下代码。
创建一个css类,如下所示
.hide
{
display:none;
}
并将css属性分配给字段,如下所示
fields: [
{ name: "Account", width: 150, align: "center" },
{ name: "Name", type: "text" },
{ name: "AccountID", css: "hide", width: 0}
]
希望这会对你有所帮助。
答案 2 :(得分:4)
fields: [
{ name: "Account", width: 150, align: "center" },
{ name: "Name", type: "text" },
{ name: "AccountID", visible: false, width: 0}]
答案 3 :(得分:0)
fields: [{
name: "<FIELD NAME>",
visible: false
}
]
答案 4 :(得分:0)
隐藏非常简单,使其类似于以下示例:
{ name: "id", title: "Id", type: "text", width: 1, css:"hide"}
CSS类从bootsrap隐藏
答案 5 :(得分:0)
就我而言,我们启动了应用程序以在JSGrid中显示一列,并一直进行生产。后来有必要隐藏该列,但我使用该列进行自定义排序。这就是我的做法
我的风格
.idStyle:
{
color: red;
}
创建了新样式
.hiddenStyle:
{
display: none;
}
下面是我的jsGrid字段
var jsGridField =
[
{ name: "Student ID", type: "text", width: "auto", css: "idStyle hiddenStyle" },
{ name: "Student Name", type: "text", width: "auto", css: "labelStyle" },
]