【问题标题】:jqGrid frozen columns when there are hidden rows有隐藏行时jqGrid冻结列
【发布时间】:2012-04-21 22:59:54
【问题描述】:

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

【问题讨论】:

    标签: javascript jquery jqgrid


    【解决方案1】:

    您是指隐藏行还是隐藏列?目前 - 从 4.3.2 开始 - 冻结列有 the following limitations:

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

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

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

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

    【讨论】:

    • 感谢您的回答。我的意思是隐藏的ROWS。这是一个例子(不是我做的): [demo][1] [1]: jsfiddle.net/YWVA8/144 如果您尝试以这种方式隐藏一行: document.getElementById("1").style.display = '没有任何';然后冻结列,框架无法正常工作: $("#list47").jqGrid("destroyFrozenColumns") .jqGrid("setColProp","id",{frozen:true}) .jqGrid("setColProp ","invdate",{frozen:true}) .jqGrid("setFrozenColumns") .trigger("reloadGrid");
    【解决方案2】:

    这是一个完整的例子:

    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")
    

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

    【讨论】:

      猜你喜欢
      • 2017-08-12
      • 2023-03-03
      • 2011-06-02
      • 1970-01-01
      • 2013-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多