假設我知道哪個行索引的目標(與this.rowToBeDeleted有一個值爲2,說),我怎麼能隱藏這一行只從網格,而不是商店(我有一個商店的標誌,這表示在我的PHP web服務代碼中稍後應該從db中刪除哪些行)。如何隱藏ExtJS GridPanel中的行?
回答
您可以使用store.filter()
方法之一,也可以隱藏行元素。
grid.getView().getRow(rowIndex).style.display = 'none';
我認爲這是更好的,雖然只刪除從商店的記錄,並讓店,因爲要刪除的記錄,而不只是隱藏它更新視圖。對於批處理模式下的商店(默認值:batch:true,restful:false),它會記住您已刪除哪些行,並且在您致電store.save()
之前不會向服務器發出請求。
您可以使用store.filter()
或store.filterBy()
方法。
在您的記錄中設置一個「隱藏」屬性,並篩選隱藏設置爲true的所有記錄。這樣他們仍然會出現在商店中,但在網格中不可見。
我建議使用store.FilterBy()
和傳遞函數測試值在rowToBedeleted值:
store.filterBy(function(record) {
return record.get("rowToBeDeleted") != 2;
});
我寫了一篇關於gridfiltering前一陣子一個基本的博文,你可以在這裏閱讀:http://aboutfrontend.com/extjs/extjs-grid-filter/
在ExtJS 4.1中,沒有view.getRow(..)
。相反,你可以使用:
this.view.addRowCls(index, 'hidden');
隱藏的行指定索引處,並
this.view.removeRowCls(index, 'hidden');
顯示它(其中「這」是網格)。
CSS類hidden
被定義爲
.hidden,
{
display: none;
}
這是特有scenarious有用的store.filterBy()
是不合適的。
謝謝,這個幫了很多。過濾器取消選擇被過濾掉的功能,但這不是。 – 2017-10-18 09:18:14
在網格js文件中寫入以下代碼,將CSS應用於要隱藏的那些行。
<pre><code>
Ext.define('MyGrid',{
extend : 'Ext.grid.Panel',
xtype : ''mygrid',
viewConfig : {
getRowClass : function(record,id){
if(record.get('rowToBeDeleted') == 2){
return 'hide-row';
}
}
},
.................
.................
});
</code></pre>
現在custom.css文件中定義自定義CSS:
.hide-row{display:none}
這將隱藏在網格行,而不從商店移除或過濾。
- 1. ExtJS GridPanel行點擊
- 2. 的GridPanel的ExtJS選擇行
- 3. 的ExtJS的GridPanel
- 4. ExtJS GridPanel寬度
- 5. Extjs GridPanel驗證
- 6. Extjs中的GridPanel未加載
- 7. 隱藏在ExtJS的
- 8. 如何動態顯示/隱藏extjs Grid中的列?
- 9. extjs顯示'列'下的隱藏列
- 10. 如何隱藏選擇ExtJS的
- 11. ExtJS Gridpanel列寬+ forcefit
- 12. 如何將ExtJS GridPanel導出到Excel?
- 13. 如何隱藏extjs網格列名稱?
- 14. ExtJS - 動態格式化GridPanel行?
- 15. 如何隱藏在ExtJS的行動列4
- 16. ExtJS中的垂直滾動條GridPanel
- 17. ExtJS的GridPanel中拖放功能
- 18. 在Extjs中刪除GridPanel的headertoolbar
- 19. ExtJS的GridPanel中選擇模式
- 20. ExtJS的GridPanel中加載datafrom數據庫
- 21. ExtJS GridPanel numberColumn - 排序問題
- 22. sencha extjs GridPanel SaveState格式
- 23. ExtJs Gridpanel商店刷新
- 24. EXTJS GridPanel選擇模型
- 25. ExtJs Gridpanel Json商店更新
- 26. 隱藏ExtJS面板標題
- 27. 無法隱藏extjs面板
- 28. 如何隱藏行組中的一行?
- 29. 如何編程隱藏選項卡中的TabPanel(ExtJS的3)
- 30. 如何將圖像置於ExtJS GridPanel的列中?
謝謝,不錯博客文章 – 2011-06-11 21:08:11