简体   繁体   English

是否有可能使sencha touch 2.0列表组件可以扩展其项目?

[英]Is it possible to make sencha touch 2.0 list component to have its items expandable?

I have a list component which is filled out using a data store(data loaded from server as json). 我有一个列表组件,使用数据存储(从服务器加载的数据作为json)填写。 A part of data from data store is displayed as list items, and i need some kind of a "+" button to the left of it to expand a list item(and "-" to collapse) to reveal(/hide) the remaining info. 来自数据存储的数据的一部分显示为列表项,我需要在其左侧使用某种“+”按钮来展开列表项(和“ - ”以折叠)以显示(/隐藏)剩余的信息。 I could simply put some javascript to itemTpl tag but i've no idea how to make smooth transitions this way. 我可以简单地将一些javascript添加到itemTpl标签,但我不知道如何以这种方式进行平滑过渡。 Maybe am missing some standard settings for a list component, but i can't find any info. 也许我错过了列表组件的一些标准设置,但我找不到任何信息。 Any help appreciated. 任何帮助赞赏。

There is no standard settings to do this functionality. 没有标准设置来执行此功能。 But this is possible to achieve. 但这有可能实现。 You can have your item template as something like this: 您可以将项目模板设为如下所示:

itemTpl: '<div class="plus"></div><div class="title">{title}</div><div class="hidden">{mydetails}</div>'

Initially, the details is hidden. 最初,隐藏细节。 You need to handle the animation when your taps the list item. 您需要在点击列表项时处理动画。 So, in your event you will have to do: 因此,在您的活动中,您将不得不这样做:

itemtap: function(view,index,htmlElement,e,opts) {

    // change the div plus to minu..
    // Get hold of the div with details class and animate
    var el = htmlElement.select('div[class=hidden]');

    el.toggleCls('hidden'); //remove the hidden class if available..
    el.show(true); // show with animation

} }

The object is obtained from select() method is Ext.dom.CompositeElementLite .. Refer this class for more methods. select()方法获得的对象是Ext.dom.CompositeElementLite ..请参阅此类以获取更多方法。 You can call the Ext.Anim from this object as well.. 你也可以从这个对象调用Ext.Anim ..

To animate you can use the Ext.Anim class. 要设置动画,可以使用Ext.Anim类。 Once you have the html element of you 'details' div, you can: 一旦你拥有了'详细信息'div的html元素,你就可以:

Ext.Anim.run(detailsDiv,'slide',{
    out:false,
    from: 'hiddenCSS',
    to: 'visibleCSS'
});

Refer to Anim class for more setting that might be needed to have your desired effect. 有关获得所需效果可能需要的更多设置,请参阅Anim类。 Also note that you will have to track the previously clicked (expanded) list items. 另请注意,您必须跟踪之前单击的(展开的)列表项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM