当有隐藏行时,jqGrid冻结列

时间:2012-04-18 13:38:02

标签: javascript jquery jqgrid

我有一个隐藏行的网格。我需要冻结前两列但我已经看到如果有一些隐藏的行'setFrozenColumns'不起作用。 谁有同样的问题?你能帮助我吗? 感谢。

2 个答案:

答案 0 :(得分:1)

你的意思是隐藏的行或隐藏的列?目前 - 从4.3.2开始 - 冻结列有the following limitations

  

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

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

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

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

答案 1 :(得分: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")

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