隐藏/删除空旋转木马卡
Hide/remove empty carousel card
我定义了一个包含(1)carousel的表单:
items: [{
xtype:'carousel',
items:[{
xtype:'fieldset'
items:[{
xtype:'textfield',
name:'overview1',
label: 'Overview 1'
}]
},{
xtype:'fieldset',
itemId:'details',
items:[{
xtype:'textfield',
name:'detail1',
label: 'Detail 1'
}]
}]
}]
和(2)构造函数
constructor:function(record) {
...
if(record.get("showDetails")) this.down('fieldset[itemId=details]').show()
else this.down('fieldset[itemId=details]').hide()
...
}
如果我有showDetails==false,则字段集被隐藏到不可见的程度。然而,旋转木马仍然有两张卡片,但是第二张是空的。我怎样从旋转木马上取下卡片?
在这种情况下,可以使用简单的面板容器与卡片布局。对于操作carousel项目,我建议查看carousel无限源代码,有rebuildInnerIndexes方法,其中项目从列表中删除
rebuildInnerIndexes: function(activeIndex) {
var indexToItem = this.innerIndexToItem,
idToIndex = this.innerIdToIndex,
items = this.innerItems.slice(),
ln = items.length,
bufferSize = this.getBufferSize(),
maxIndex = this.getMaxItemIndex(),
changedIndexes = [],
i, oldIndex, index, id, item;
if (activeIndex === undefined) {
this.innerIndexToItem = indexToItem = {};
this.innerIdToIndex = idToIndex = {};
for (i = 0; i < ln; i++) {
item = items[i];
id = item.getId();
idToIndex[id] = i;
indexToItem[i] = item;
this.fireEvent('itemindexchange', this, item, i, -1);
}
}
else {
for (i = activeIndex - bufferSize; i <= activeIndex + bufferSize; i++) {
if (i >= 0 && i <= maxIndex) {
if (indexToItem.hasOwnProperty(i)) {
Ext.Array.remove(items, indexToItem[i]);
continue;
}
changedIndexes.push(i);
}
}
for (i = 0,ln = changedIndexes.length; i < ln; i++) {
item = items[i];
id = item.getId();
index = changedIndexes[i];
oldIndex = idToIndex[id];
delete indexToItem[oldIndex];
idToIndex[id] = index;
indexToItem[index] = item;
this.fireEvent('itemindexchange', this, item, index, oldIndex);
}
}
}
希望能有所帮助
可以使用remove
/removeAt
函数来摆脱面板。然而,当选项卡可能包含表单数据时,这确实需要相当多的工作,并且应该在稍后的时间重新插入,预先填充在选项卡被删除之前的表单数据。哎呀,我还希望提交表单数据。
我用了一个函数来隐藏标签:
onActiveTabChange:function(carousel, newValue, oldValue, eOpts) {
var items = carousel.getItems(),
newIndex = items.indexOf(newValue),
details = carousel.down('field[name=DetailsTab]').getValue();
if(!details && newIndex==2) carousel.setActiveItem(0);
// WTF moment n° 4711: newIndex can be 1 or 2 because index 0 is the indicator; but setActiveItem takes 0 or 1...
},
相关文章:
- 知道为什么我的旋转木马不会自动更改图片吗
- 禁用旋转木马中的下一个按钮和上一个按钮
- 旋转木马;启用内容安全策略时无法工作
- 在引导程序旋转木马中显示下一个图像
- 猫头鹰旋转木马2罐头't使渐变动画工作
- 猫头鹰旋转木马宽度计算错误
- 猫头鹰旋转木马动画未在Chrome中应用
- 猫头鹰旋转木马:无法读取属性'visibleItems'的未定义
- 在Javascript中设置多个小图像(如旋转木马)
- 如何使引导旋转木马保持图像纵横比
- 使用旋转木马在元素上切换类
- 将图像传递到Angular UI引导旋转木马
- 当ons惰性重复检测到更改时,如何使用ons旋转木马刷新列表
- 猫头鹰旋转木马2-拖动方向
- 带有JQuery和CSS的3D旋转木马-渲染不正确
- 如何在猫头鹰旋转木马中滑动所有可见项目,而不是使用上一个/下一个按钮
- Bootstrap 3旋转木马/滑块IE9支持
- Ruby on Rails - 引导旋转木马按钮不起作用
- Bootstrap旋转木马:删除自动滑动
- 隐藏/删除空旋转木马卡