2012-03-13 99 views
1

我想使用的负载上滚动(虚拟滚动)功能为我jqGrid的数据。jqGrid的虚拟滚动(上滚动负载)设置

我一直在寻找好的文档和这样的例子,但我发现只有asp.net框架,也没有那么乐于助人。

我使用服务器端的Java Spring框架。

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

我的网格设置就是这样。

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 

} 

});

在此先感谢.. !!

回答

4

还有就是用动态的滚动和的TreeGrid在一起没有内置的方式。当您使用TreeGrid时,禁用所有分页器功能,并在初始数据加载后自动将数据类型设置为本地。您可以阅读TreeGrid文档的"Cautions and Limitations"部分中的所有限制。

UPDATE

,使其在简单的网格工作,它足以滚动设置为true:

$('#grid').jqGrid({ 
    ... 
    //enable dynamic scrolling 
    scroll: true, 
    ... 
}); 

的jqGrid将禁用寻呼机控制,并自动作出新页面的请求当你滚出当前的一个。还有一种方法可以优化这种体验。您可以在prmNames选项来启用NPAGE参数:

$('#grid').jqGrid({ 
    ... 
    //enable dynamic scrolling 
    scroll: true, 
    //enable npage request parameter 
    prmNames: { npage: 'npage' }, 
    ... 
}); 

这将允许的jqGrid通过添加NPAGE参数请求一次请求超过一个页面(它将含有jqGrid的请求的页面数量,您应该返回适当的行数)。

+0

感谢您的回复。是的,我通过了这些观点,有没有什么方法可以实现。另外,你能告诉我们如何为简单的网格(而不是treegrid)完成它。 – mayur 2012-03-13 09:54:20

+1

这个工作需要重写大部分的TreeGrid功能,因为动态加载子节点需要本地数据类型。我不知道有任何可以使用的解决方案。至于简单的网格,请阅读更新。 – tpeczek 2012-03-13 10:16:34

+0

tpeczek ...非常感谢你..我想,使它在treegrid中使用... $(“#grid”)。scroll(function(){.ajax {}});在这里我会传递最后一个行号和页码,它返回行数,这些行数反过来将会使用$(“#grid”)追加到主网格。 – mayur 2012-03-13 10:22:07