请问一下,在Combox中的数据有 1 2 3 4 5 6 7 8 9 ,
如果我想设置 在 1~3的数据显示绿色, 4~6 显示黄色,7~9显示红色,
不知道这样的效果怎么做.....请指点一下......谢谢啦
如果你要修改这个的话,可能你要改源码了,当然可以改写这个类的initList方法来实现你需要的功能
if(!this.tpl){
this.tpl = '
[code="js"]Ext.onReady(function() {
var data = [['AL', '1', 'The Heart of Dixie'],
['AK', '2', 'The Land of the Midnight Sun'],
['AZ', '3', 'The Grand Canyon State'],
['AR', '4', 'The Natural State'],
['CA', '5', 'The Golden State'],
['CO', '6', 'The Mountain State'],
['CT', '7', 'The Constitution State'],
['DE', '8', 'The First State'],
['DC', '9', "The Nation's Capital"]];
var store = new Ext.data.SimpleStore({
fields : ['abbr', 'state', 'nick'],
data : data
});
var combo = new Ext.form.ComboBox({
store : store,
displayField : 'state',
typeAhead : true,
mode : 'local',
forceSelection : true,
triggerAction : 'all',
emptyText : 'Select a state...',
selectOnFocus : true,
applyTo : 'local-states'
});
})
[/code]
如果你的数据是从服务器返回的,你可以在服务器端判断一下,根据条件来生成不同颜色的数据,不需要修改源代码:)
[img]http://yourgame.iteye.com/upload/picture/pic/34053/bb7a4855-54c7-31ea-92df-f72328adfe3b.jpg[/img]
你只需要改动你的返回的json数据即可,如下:
[code="java"]
var data=[
["y","是"],
["n","否"]
];
[/code]