Dorado 9 : Accordion(DCUG)

简介

手风琴控件

布局组件,分为多个Section,每个Section有一个标题栏和组件,Accordion中有多个Section子控件对象,设计视图: 

但同时激活的只能有一个Section,类似TabControl或者VerticalTabControl。

界面效果如下:

界面操作效果参考: 表现层组件一览中的 【Accordion】Accordion

 

关键属性使用

sections

该属性返回的的一个Section数组,可以以数组的形式访问它们:

var sections = accordion.get("sections");
sections.each(function(section)){
var name = section.get("name");
});

dorado.MessageBox.alert(sections[2].get("name"));

currentSection和currentIndex

我们可以通过Accordion的currentSection虚拟属性获取当前激活的Section对象:

//方法一
dorado.MessageBox.alert(accordion.get("currentSection.name"));
//方法二
var section = accordion.get("currentSection");
dorado.MessageBox.alert(section.get("name"));

上述代码是获取当前Section的name名称。

当然我们也可以通过currentSection虚拟属性设置当前激活哪一个Section对象,这样我们就可以不用鼠标操作就切换手风琴中的当前Section,如:

accordion.set("currentSection"), section2);

上面的代码就是将accordion控件下的section2子控件作为当前激活的Section。

除了currentSection属性,我们还可以通过Accordion控件的currentIndex设置当前激活的Section对象,如:

accordion.set("currentIndex", 2);

上面代码表示将Accordion控件中的第三个Section作为当前激活可见的Section对象。

注意:默认的序号是从0开始的

animate

这个属性决定了在切换Section的时候是否要使用动画。

事件使用

无论是鼠标操作还是通过Accordion的currentSection虚拟属性的动态设定而导致当前Section发生变化的时候都会导致下面两个事件的发生:

beforeCurrentSectionChange

在currentSection进行切换之前触发的事件,在这个事件里面currentSection属性还是切换之前的Section。

 

if (arg.oldSection){
dorado.MessageBox.alert(arg.oldSection.get("name"));
}
dorado.MessageBox.alert(arg.newSection.get("name"));

arg.processDefault属性,我们可以通过这个属性禁止currentSection切换,如:

 

if  (arg.newSection.get("name")=="section2"){
	arg.processDefault = false;
}


onCurrentSectionChange

在currentSection进行切换之后触发的事件,在这个事件里面currentSection属性已经是切换之后的Section。

Attachments:

AccordionView.PNG (image/png)
AccordionPreview.PNG (image/png)