当我点击JQGrid子网格中的任何不可编辑单元格时,如何避免滚动到顶部...?

时间:2011-10-13 10:16:24

标签: jqgrid

我在JQGrid中使用单元格编辑作为子网格。

当我将子网格的高度设置为自动时,通过单击不可编辑的单元格,网格滚动回到顶部。

当我将高度设置为特定的180或者其他东西时,这样,它就不会滚动到顶部。选定的细胞保持相同的位置。

如果我需要自动制作高度,我应该如何避免滚动到顶部?

$("#listsg11").jqGrid({
url:'Any URL',
datatype: "json",
height: 190,
colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
colModel:[
    {name:'id',index:'id', width:55},
    {name:'invdate',index:'invdate', width:90},
    {name:'name',index:'name', width:100},
    {name:'amount',index:'amount', width:80, align:"right"},
    {name:'tax',index:'tax', width:80, align:"right"},      
    {name:'total',index:'total', width:80,align:"right"},       
    {name:'note',index:'note', width:150, sortable:false}       
],
sortname: 'id',
viewrecords: true,
sortorder: "desc",
multiselect: false,
subGrid: true,
caption: "Grid as Subgrid",
subGridRowExpanded: function(subgrid_id, row_id) {
    var subgrid_table_id, pager_id;
    subgrid_table_id = subgrid_id+"_t";

    $("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>");
    jQuery("#"+subgrid_table_id).jqGrid({
        url:'Any URL with parameters',
        datatype: "json",
        colNames: ['No','Item','Qty','Unit','Line Total'],
        colModel: [
            {name:"num",index:"num",width:80,key:true},
            {name:"item",index:"item",width:130,editable:true},
            {name:"qty",index:"qty",width:70,align:"right",editable:true},
            {name:"unit",index:"unit",width:70,align:"right",editable:false},
            {name:"total",index:"total",width:70,align:"right",sortable:false}
        ],
        cellEdit: true,
        cellsubmit: 'clientArray',
            height: 'auto'
    });

} });

提前致谢。

1 个答案:

答案 0 :(得分:0)

我使用子网格作为网格,与链接中的给定示例相同, 以下是一个示例代码,我在其中进行了更改以重新生成问题。 我不在任何网格中使用寻呼机div。我将Subgrid的高度设置为'auto'

当您点击子网格的最后一行中的任何不可编辑的CELL时。子网格应该导航回顶部,但不是我选择的单元格

注意:子网格数据应该超过30行。

由于