2012-03-13 23 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