当我单击JQGrid子网格中的任何“不可编辑的单元格"时,如何避免滚动到顶部? [英] How to avoid scroll to top, when i click on any Non-Editable Cell in JQGrid subgrid...?

查看:71
本文介绍了当我单击JQGrid子网格中的任何“不可编辑的单元格"时,如何避免滚动到顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对JQGrid中的子网格使用单元格编辑.

I'm using Cell Editing for a sub-grid in JQGrid.

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

When I set height of sub-grid to auto, By clicking on non editable cell, Grid scroll back to top.

当我将高度设置为180之类的特定值时,那样,它不会滚动到顶部.所选单元格保持在相同位置.

And when i set height to be specific like 180 or something, That way, it does not scrolls to top. Selected cell remains in same position.

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

If i need to make height auto, How should i avoid scrolling back to top?

$("#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'
    });

} });

谢谢.

推荐答案

我正在使用子网格作为网格,就像您的链接中给出的示例一样, 下面是一个示例代码,在其中我进行了更改以重现该问题. 我没有在任何网格中使用pager div.我将Subgrid的高度设置为自动"

I'm using subgrids as grid, Same like given example in your link, And following is an example code in which I've made changes to re-produce the problem. I do not use pager div in any of my grids. And I've set height of Subgrid as 'auto'

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

When you click on any non editable CELL in last row of subgrid. Sub-grid should navigate back to top, But not my selected cell

注意:子网格数据大约应超过30行.

Note: Subgrid data should be more than 30 rows approx.

谢谢

这篇关于当我单击JQGrid子网格中的任何“不可编辑的单元格"时,如何避免滚动到顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆