1

我有一个带有一些隐藏行的网格。我需要冻结前两列,但我发现如果有一些隐藏的行,'setFrozenColumns' 不起作用。有同样问题的人吗?你能帮助我吗?谢谢。

4

2 回答 2

1

你的意思是隐藏行还是隐藏列?目前 - 从 4.3.2 开始 - 冻结列具有以下限制

以下限制告诉您何时无法设置冻结列

  • 启用 TreeGrid 时
  • 启用子网格时
  • 启用 cellEdit 时
  • 使用内联编辑时 - 无法编辑冻结的列。
  • 启用可排序列时 - 网格参数 sortable 设置为 true 或者是函数
  • 当滚动设置为 true 或 1
  • 启用数据分组时

因此,如果您使用的是 TreeGrid 或 SubGrid,冻结列将根本不起作用。

如果您的意思是您有隐藏的,那么冻结的列应该可以工作 - 您可能需要发布代码或演示问题的小示例。

于 2012-04-18T14:12:07.737 回答
0

这是一个完整的例子:

var mydata = [
{
id: "1",
invdate: "2010-05-24",
name: "test",
note: "note",
tax: "10.00",
total: "2111.00"},
{
id: "2",
invdate: "2010-05-25",
name: "test2",
note: "note2",
tax: "20.00",
total: "320.00"},
{
id: "3",
invdate: "2007-09-01",
name: "test3",
note: "note3",
tax: "30.00",
total: "430.00"},
{
id: "4",
invdate: "2007-10-04",
name: "test",
note: "note",
tax: "10.00",
total: "210.00"},
{
id: "5",
invdate: "2007-10-05",
name: "test2",
note: "note2",
tax: "20.00",
total: "320.00"},
{
id: "6",
invdate: "2007-09-06",
name: "test3",
note: "note3",
tax: "30.00",
total: "430.00"},
{
id: "7",
invdate: "2007-10-04",
name: "test",
note: "note",
tax: "10.00",
total: "210.00"},
{
id: "8",
invdate: "2007-10-03",
name: "test2",
note: "note2",
amount: "300.00",
tax: "21.00",
total: "320.00"},
{
id: "9",
invdate: "2007-09-01",
name: "test3",
note: "note3",
amount: "400.00",
tax: "30.00",
total: "430.00"},
{
id: "11",
invdate: "2007-10-01",
name: "test",
note: "note",
amount: "200.00",
tax: "10.00",
total: "210.00"},
{
id: "12",
invdate: "2007-10-02",
name: "test2",
note: "note2",
amount: "300.00",
tax: "20.00",
total: "320.00"},
{
id: "13",
invdate: "2007-09-01",
name: "test3",
note: "note3",
amount: "400.00",
tax: "30.00",
total: "430.00"},
{
id: "14",
invdate: "2007-10-04",
name: "test",
note: "note",
amount: "200.00",
tax: "10.00",
total: "210.00"},
{
id: "15",
invdate: "2007-10-05",
name: "test2",
note: "note2",
amount: "300.00",
tax: "20.00",
total: "320.00"},
{
id: "16",
invdate: "2007-09-06",
name: "test3",
note: "note3",
amount: "400.00",
tax: "30.00",
total: "430.00"},
{
id: "17",
invdate: "2007-10-04",
name: "test",
note: "note",
amount: "200.00",
tax: "10.00",
total: "210.00"},
{
id: "18",
invdate: "2007-10-03",
name: "test2",
note: "note2",
amount: "300.00",
tax: "20.00",
total: "320.00"},
{
id: "19",
invdate: "2007-09-01",
name: "test3",
note: "note3",
amount: "400.00",
tax: "30.00",
total: "430.00"},
{
id: "21",
invdate: "2007-10-01",
name: "test",
note: "note",
amount: "200.00",
tax: "10.00",
total: "210.00"},
{
id: "22",
invdate: "2007-10-02",
name: "test2",
note: "note2",
amount: "300.00",
tax: "20.00",
total: "320.00"},
{
id: "23",
invdate: "2007-09-01",
name: "test3",
note: "note3",
amount: "400.00",
tax: "30.00",
total: "430.00"},
{
id: "24",
invdate: "2007-10-04",
name: "test",
note: "note",
amount: "200.00",
tax: "10.00",
total: "210.00"},
{
id: "25",
invdate: "2007-10-05",
name: "test2",
note: "note2",
amount: "300.00",
tax: "20.00",
total: "320.00"},
{
id: "26",
invdate: "2007-09-06",
name: "test3",
note: "note3",
amount: "400.00",
tax: "30.00",
total: "430.00"},
{
id: "27",
invdate: "2007-10-04",
name: "test",
note: "note",
amount: "200.00",
tax: "10.00",
total: "210.00"},
{
id: "28",
invdate: "2007-10-03",
name: "test2",
note: "note2",
amount: "300.00",
tax: "20.00",
total: "320.00"},
{
id: "29",
invdate: "2007-09-01",
name: "test3",
note: "note3",
amount: "400.00",
tax: "30.00",
total: "430.00"}
];
jQuery("#list47").jqGrid({
data: mydata,
datatype: "local",
height: 150,
rowNum: 999999,
scroll: false,
shrinkToFit: false,
width: 350,
colNames: ['Inv No', 'Date', 'Client', 'Amount', 'Tax', 'Total', 'Notes'],
colModel: [
    {
    name: 'id',
    index: 'id',
    width: 60,
    sortable: false, frozen: true},
{
    name: 'invdate',
    index: 'invdate',
    width: 90,
    sorttype: "date",
    formatter: "date"},
{
    name: 'name',
    index: 'name',
    width: 100},
{
    name: 'amount',
    index: 'amount',
    width: 80,
    align: "right",
    sorttype: "float",
    formatter: "number"},
{
    name: 'tax',
    index: 'tax',
    width: 80,
    align: "right",
    sorttype: "float"},
{
    name: 'total',
    index: 'total',
    width: 80,
    align: "right",
    sorttype: "float"},
{
    name: 'note',
    index: 'note',
    width: 150,
    sortable: false}
],

pager: "#plist47",
viewrecords: true,
multiselect: true,
caption: "single selection",
beforeSelectRow: function(rowid, e)
{
    //jQuery("#list47").jqGrid('resetSelection');
    //return(true);
}

});



document.getElementById("1").style.display = 'none';
$("#list47").jqGrid("destroyFrozenColumns") 
                .jqGrid("setColProp","id",{frozen:true})
                .jqGrid("setColProp","invdate",{frozen:true})                 
                .jqGrid("setFrozenColumns")

在这种情况下,只是标题被冻结,而不是整个列。

于 2012-04-21T14:59:54.343 回答