How to avoid scroll to top, when i click on any Non-Editable Cell in JQGrid subgrid…?

走远了吗. 提交于 2020-01-17 01:15:15

问题


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.

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'
    });

} });

Thanks in advance.


回答1:


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'

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

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

Thanks



来源:https://stackoverflow.com/questions/7752611/how-to-avoid-scroll-to-top-when-i-click-on-any-non-editable-cell-in-jqgrid-subg

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!