可点击的列/栏/水平布局与 sencha
我在尝试使 sencha 上的列可点击时遇到问题。我尝试了各种方法,将文本放入容器、组件等中,但我无法让它对点击做出反应。
这是代码片段。检查一下监听器,当我点击文本或布局栏时它不起作用。请帮忙!
app.views.test = Ext.extend(Ext.Panel, {
scroll: "vertical",
id: 'test',
initComponent: function() {
var testbar = {
layout : {
type : 'vbox',
align : 'start',
pack : 'start'
},
width : '60%',
items : [{
html : 'press this column
bar : '5 0 0 15',
width : '100%'
}],
listeners: {
itemtap : function () {
console.log("goto next");
}
}
};
var testViews = {
items : [ testbar ]
};
this.items = [ testViews ];
app.views.test.superclass.initComponent.apply(this, arguments);
},
onSelect: function(sel, records){
if (records[0] !== undefined) {
}
}
});
I have a problem trying to make a column clickable on sencha. I tried various ways, putting the text in a container, component, etc and I cant get it to react to a click.
Here is the code snippet. Check out the listener, it doesnt work when I tap on the text or that layout bar. Please help!
app.views.test = Ext.extend(Ext.Panel, {
scroll: "vertical",
id: 'test',
initComponent: function() {
var testbar = {
layout : {
type : 'vbox',
align : 'start',
pack : 'start'
},
width : '60%',
items : [{
html : 'press this column
bar : '5 0 0 15',
width : '100%'
}],
listeners: {
itemtap : function () {
console.log("goto next");
}
}
};
var testViews = {
items : [ testbar ]
};
this.items = [ testViews ];
app.views.test.superclass.initComponent.apply(this, arguments);
},
onSelect: function(sel, records){
if (records[0] !== undefined) {
}
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
至于回答你最后的评论,不,如果你不需要大多数面板的功能,vbox 可能有点过分了。我建议只使用纯 dom。 pure dom 的好处是你可以完全控制你需要的东西。如果您使用 vbox,您最终将否定或禁用它提供的一些 css/功能。
首先,这是纯dom方法: 链接到示例
然后,这是vbox方式。请注意我如何在单个循环中创建它们: 转到示例
它们看起来都很相似,只是 vbox 方式有点矫枉过正,因为它比使用纯 dom 处理的东西多一点。检查两个生成的 dom 节点以查看差异。
这是示例 1 中生成的 dom 节点:
这是示例 2 中的:
明白我的意思了吗?
As to answer your last comment, no, vbox might be overkill if you do not need most panel's functionalities. I would suggest to just use pure dom. The good thing about pure dom is that it you have your full control over what you need. If you use
vbox
, you will end up negating or disabling some of the css/functionalities it is providing.So first, this is pure dom method: link to example
And then, this is the vbox way. Notice how I create them in a single loop: go to example
Both of them looks similar, just vbox way is a little bit overkilling as it processed a little bit more stuff than using pure dom. Inspect both generated dom nodes to see the differences.
This is the dom nodes generated in example 1:
And this is in example 2:
Get what I mean?