우리는 일련의 단추를 표시하기 위해 DataView를 사용하고 있습니다. 데이터는 상점에서 가져오고 여기에있는 각 모델에는 단추의 배경색이 들어 있습니다. 버튼의 텍스트를 변경할 수는 있지만 모델의 값을 기반으로 배경색을 변경하려면 어떻게해야합니까?Sencha Touch : 동적 단추 배경
이것은 ButtonData 모델입니다 :이 예제를 바탕으로
Ext.define('Sencha.model.ButtonData', {
extend: 'Ext.data.Model',
config: {
fields: [
{name: 'text', type: 'auto'},
{name: 'color', type: 'auto'}
]
}
});
http://www.sencha.com/blog/dive-into-dataview-with-sencha-touch-2-beta-2 나는이 설정과 함께있는 DataItem이 있습니다
config : {
dataMap: {
getButton : { setText: 'text'}, // works!
//problem is here: how do I set the background color based on the 'color'
// member form the 'ButtonData' model?
},
button: {
ui: 'plain'
}
}
그래서 문제가 어떻게 설정하는 방법을 'color'멤버를 기반으로하는 배경색은 'ButtonData'모델을 형성합니까?
들으,
마틴
결국 우리는 비슷한 접근법을 사용했습니다. 즉, Button에서 클래스를 파생시키고 setColor 함수를 추가하여 색상을 변경했습니다. 대답은 Thx입니다. – Maarten