gpt4 book ai didi

javascript - 如何让 ExtJs RowExpander 仅在某些行上显示图标 ([+])?

转载 作者:行者123 更新时间:2023-11-30 17:37:14 28 4
gpt4 key购买 nike

我正在使用 RowExpander 来显示有关网格中每一行的附加信息。有些行没有任何附加信息。对于这些行,如何让展开图标(加号)不被渲染?有没有可以像过滤器一样使用的函数?

我在这里看到了一个类似的问题,它说有一个名为 renderer() 的函数,但我试过了,但它没有被调用。

最佳答案

我想出了一个解决问题的办法。我扩展了 RowExpander 插件并将 getHeaderConfig 函数复制并粘贴到我的新插件中。这使我能够对渲染器函数进行必要的更改,以检查每条记录是否有任何要显示在 rowBody/rowExpander 中的内容

Ext.define('MyApp.plugins.RowExpander', {
extend: 'Ext.grid.plugin.RowExpander',
alias: 'plugin.rowexpanderplus',
getHeaderConfig: function () {
var me = this;

return {
width: 24,
lockable: false,
sortable: false,
resizable: false,
draggable: false,
hideable: false,
menuDisabled: true,
tdCls: Ext.baseCSSPrefix + 'grid-cell-special',
innerCls: Ext.baseCSSPrefix + 'grid-cell-inner-row-expander',
renderer: function (value, metadata, record, a, b, store, grid) {
if (record.data.notes.length === 0) {
return '<div></div>';
}

// Only has to span 2 rows if it is not in a lockable grid.
if (!me.grid.ownerLockable) {
metadata.tdAttr += ' rowspan="2"';
}
return '<div class="' + Ext.baseCSSPrefix + 'grid-row-expander" role="presentation"></div>';
},
processEvent: function (type, view, cell, rowIndex, cellIndex, e, record) {
if (type == "mousedown" && e.getTarget('.' + Ext.baseCSSPrefix + 'grid-row-expander')) {
me.toggleRow(rowIndex, record);
return me.selectRowOnExpand;
}
}
};
}
});

这不是我想要做的,但我查看了插件的源代码,但我看不出有什么方法可以 Hook 渲染器。

关于javascript - 如何让 ExtJs RowExpander 仅在某些行上显示图标 ([+])?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21788003/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com