假設我知道哪個行索引的目標(與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. 如何隱藏/刪除GridPanel中的行
- 2. EXTJS 4.1 - 如何GridPanel中
- 3. ExtJS GridPanel行點擊
- 4. ExtJS的4.2.1的GridPanel - 在模板列顯示/隱藏鏈接
- 5. 的GridPanel的ExtJS選擇行
- 6. Exjts4:如何將GridPanel中的列動態設置爲在我的GridPanel中隱藏
- 7. 的ExtJS的GridPanel
- 8. Extjs GridPanel驗證
- 9. ExtJS GridPanel寬度
- 10. Extjs中的GridPanel未加載
- 11. ExtJS的隱藏colorfield
- 12. 隱藏在ExtJS的
- 13. 如何動態顯示/隱藏extjs Grid中的列?
- 14. extjs顯示'列'下的隱藏列
- 15. 如何隱藏選擇ExtJS的
- 16. ExtJS Gridpanel列寬+ forcefit
- 17. extjs gridpanel not showing scrollbars
- 18. ExtJS。隱藏容器
- 19. 如何計算gridpanel號碼列extjs
- 20. 如何將ExtJS GridPanel導出到Excel?
- 21. 帶Textfield列的ExtJS Gridpanel
- 22. 如何隱藏extjs網格列名稱?
- 23. ExtJS的隱藏href的值
- 24. ExtJS的3.4 GridPanel中不FormPanel中
- 25. 新增行不能拖放在extjs gridpanel
- 26. ExtJS - 動態格式化GridPanel行?
- 27. ExtJS 3.4.0 GridPanel條件禁用行
- 28. ExtJS的 - GridPanel中的所有檢查
- 29. 如何隱藏在ExtJS的行動列4
- 30. ExtJS的GridPanel中選擇模式
謝謝,不錯博客文章 – 2011-06-11 21:08:11