首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jqgrid虚拟滚动(滚动加载)设置

jqgrid虚拟滚动(滚动加载)设置
EN

Stack Overflow用户
提问于 2012-03-13 17:05:47
回答 1查看 12.5K关注 0票数 1

我想对jqgrid中的数据使用load on scroll(虚拟滚动)功能。

我一直在寻找好的文档和示例,但我只找到了asp.net框架,它们也没有那么有帮助。

我在服务器端使用java-spring框架。

请建议一些方法来实现我的网格虚拟滚动功能。

我的网格设置是这样的。

代码语言:javascript
复制
jQuery("#tree").jqGrid({
    url:'json/jsonSamplePots.json',
    datatype: "json",
    mtype:'GET',
    colNames: ["id", "no.", "name", "col1", "col2", "col3", "col4", "col5", "col6", "col7", "col8", "col9", "col10", "col11", "col12", "col13", "col14", "col15", "col16"],
    colModel: [
        {name:'id',width: 30, editable:false, align:"right",sortable:false, hidden: true, key: true},
        {name:'no',width:80, editable:false, align:"left", sortable:true, sorttype:"int"},
        {name:'name', width:150, editable:true, sortable:true, sorttype:"text"},
        {name:'col1', width:80, editable:true, align:"right", sortable:true, sorttype:"int"},
        {name:'col2', width:80, editable:true, align:"right", sortable:true, sorttype:"date"},
        {name:'col3', width:80, editable:true, align:"right", sortable:true, sorttype:"date"},
        {name:'col4', width:80, editable:true, align:"right", sortable:true, sorttype:"int"},
        {name:'col5', width:80, editable:false, align:"right", sortable:true, hidden: true, sorttype:"date"},
        {name:'col6', width:80, editable:false, align:"right", sortable:true, hidden: true, sorttype:"date"},
        {name:'col7', width:80, editable:false, align:"right", sortable:true, hidden: true, sorttype:"int"},
        {name:'col8', width:80, editable:false, align:"right", sortable:true, hidden: true, sorttype:"date"},
        {name:'col9', width:80, editable:false, align:"right", sortable:true, hidden: true, sorttype:"date"},
        {name:'col10', width:80, editable:false, align:"right", sortable:true, hidden: true, sorttype:"int"},
        {name:'col11', width:120, editable:true, align:"left", sortable:true, sorttype:"text"},
        {name:'col12', width:80, editable:true, align:"left", sortable:true, sorttype:"text"},
        {name:'col13', width:80, editable:true, align:"right", sortable:true, hidden: true, sorttype:"text"},
        {name:'col14', width:80, editable:false, align:"right", sortable:true, hidden: true, sorttype:"text"},
        {name:'col15', width:300, editable:true, align:"left", sortable:true, sorttype:"int"},
        {name:'col16', width:80, editable:true, align:"right", sortable:true, sorttype:"int"},
    ],

    treeGridModel:'adjacency',
    treeGrid: true,
    cellEdit: true,
    ExpandColumn:'name',
    cellsubmit : 'clientArray',
    scroll : 1,
    loadonce : false,
    jsonReader : {
 root:"listTasks",
 cell:"",
 id: "id",
 repeatitems:false

}

});

提前谢谢..!!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-13 17:48:31

没有内置的方式来同时使用动态滚动和TreeGrid。当您使用TreeGrid时,所有分页功能都被禁用,并且数据类型在初始数据加载后自动设置为local。您可以在TreeGrid文档的"Cautions and Limitations"部分了解所有限制。

更新

要让它在简单的网格中工作,只需将scroll设置为true即可:

代码语言:javascript
复制
$('#grid').jqGrid({
  ...  
  //enable dynamic scrolling
  scroll: true,
  ...
});

jqGrid将禁用页面导航控件,并在您滚动出当前页面时自动请求一个新页面。还有一种方法可以优化这种体验。您可以在prmNames选项中启用npage参数:

代码语言:javascript
复制
$('#grid').jqGrid({
  ...
  //enable dynamic scrolling
  scroll: true,
  //enable npage request parameter
  prmNames: { npage: 'npage' },
  ...
});

这将允许jqGrid通过向请求添加npage参数来一次请求多个页面(它将包含jqgrid正在请求的页面数量,您应该返回适当的行数)。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9681021

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档