外部数据视图,NestedList不会自动调整其高度

cwxwcias  于 2022-09-26  发布在  其他
关注(0)|答案(1)|浏览(190)

我使用移动Modern接口ExtJs 7
需要不滚动的列表。你能告诉我如何制作Ext.dataview吗。NestedList中的项数更改时,是否自动调整其高度?

hpxqektj

hpxqektj1#

我有一个网格类(grid extends dataview),它将随着行的添加而增长和收缩。当它达到7行时,它停止增长并开始滚动。这很有效,因为我可以预测网格中的行高度。

  1. // this is jsut so we can resize the grid on the screen.
  2. // this functionality should be moved to a plugin or a mixin... i think.
  3. // it is a bit comlicated because I am using a viewmodel in the grid and
  4. // i don't know if you can do that with a mixin or plugin.
  5. // so i just exteded the grid and created its own xtype. this is used
  6. // in both the customer and item eligiability panels...
  7. Ext.define("Common.ui.grid.Resize", {
  8. extend: 'Ext.grid.Grid',
  9. xtype: 'grid-resize',
  10. loadingText: null,
  11. striped: true,
  12. viewModel: {
  13. formulas: {
  14. countChange: {
  15. // checking to see if the count has changed for the store that this grid is using.
  16. // if the count changes we resize the grid but only to a max of hold 7 rows then
  17. // it is scrolling.
  18. // bind: {
  19. // items: '{activeStore.count}'
  20. // // collections: '{collections.count}'
  21. // // bindTo: '{items.count}',
  22. // },
  23. bind: {
  24. bindTo: '{__store.count}',
  25. },
  26. get: function (rows) {
  27. // resizing a hidden grid will return a zero hiehght for the
  28. // header. so if the grid is hidden we do a single show event
  29. // and reize the grid after it is shown.
  30. // also if the grid has never been rendered then the rowHeight is null
  31. var grid = this.getView();
  32. if (grid.isHidden()) {
  33. grid.onShowEvent = grid.on("show", grid.resizeGrid, this, {
  34. single: true
  35. });
  36. } else {
  37. grid.resizeGrid(grid);
  38. }
  39. }
  40. },
  41. },
  42. },
  43. onShowEvent: null,
  44. resizeGrid: function (grid) {
  45. // this method is either called directly when the
  46. // count on the store has changed.... or
  47. // is called via a "show" event on the grid.
  48. // the scope does not really matter because
  49. // we are passing all needed stuff...
  50. if (grid.getStore() != null) {
  51. var rows = grid.getStore().getCount();
  52. // console.log('getting items count %o %o', rows, arguments);
  53. // console.log("GRID? %o ", grid);
  54. // console.log("GRID? hidden %o ", grid.getHidden());
  55. // console.log("GRID? hidden(is) %o ", grid.isHidden());
  56. // console.log("ROWS %o", rows);
  57. if (rows > 7) {
  58. rows = 7;
  59. }
  60. var rowHeight = grid.rowHeight;
  61. // console.log("row height pos 1 %o", rowHeight);
  62. if (rowHeight == null || rowHeight == 0) rowHeight = 41;
  63. // console.log("row height pos 2 %o", rowHeight);
  64. var newHeight = (rowHeight * rows)
  65. // console.log("newHeight pos 1 %o", newHeight);
  66. newHeight = newHeight + grid.getHeaderContainer().element.getHeight();
  67. // console.log("newHeight pos 2 %o", newHeight);
  68. grid.updateHeight(newHeight);
  69. Ext.defer(function () {
  70. this.refresh();
  71. }, 1000, grid);
  72. }
  73. },
  74. selectable: {
  75. rows: true
  76. },
  77. listeners: {
  78. storechange: function (grid) {
  79. // switching between the item and the collection grid...will be different number of items
  80. // so need to resize.
  81. grid.resizeGrid(grid);
  82. }
  83. },
  84. // this makes the columns menu on the header.... where you show/hide columns.....
  85. // scrollable so if it extends beyond the screen you can still get to the items.
  86. // still need to intellegently figure out the maxHeight.
  87. columnsMenuItem: {
  88. menu: {
  89. scrollable: true,
  90. maxHeight: '500px'
  91. }
  92. },
  93. height: '300px',
  94. width: '100%',
  95. privates: {
  96. applyStore: function (store, oldStore) {
  97. console.log("RESIZE GRID APPLY STORE IN REIZE GGRID MIXIN");
  98. this.getViewModel().set("__store", store);
  99. return this.callParent([store, oldStore]);
  100. }
  101. }
  102. });
展开查看全部

相关问题