+++++++++++extjs combobox 列表颜色设定++++++++ 本帖最后由 kong19 于 2010-07-20 13:16:06 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 上一贴中我把grid.render=function(data, metadata, record, rowIndex, columnIndex, store) { if(条件){ //这里可以根据rowIndex,columnIndex 设置字体颜色 return '<span style="color:red;"><B>' + record.data["Number"] + '</B></span>'; } else { return record.data["Number"]; } }但是执行的时候后面的四个参数都是null,~ 不知道是不是我上面的代码抄的不对~~~combo用同样方法应该也可以实现颜色的设置吧? var s = new Ext.form.ComboBox({ renderTo: Ext.getBody(), mode: 'local', editable:false, width: 120, triggerAction: 'all', displayField:'displayText', valueField: 'value', store: new Ext.data.SimpleStore({ fields : ['displayText','value' ], data : [[ '红','red'], ['蓝', 'blue']] }), listeners: { change: function (c) { c.getEl().dom.style.color = c.value; //在这个事件中做其他的操作,如改变颜色 } } }); 这个要设置在header的选项中cm:[{ header: 'head', dataIndex: "tou", renderer: function(data, metadata, record, rowIndex, columnIndex, store) { if(条件){ ....}] grid.render=function(data, metadata, record, rowIndex, columnIndex, store) 写成这样肯定后面的参数都null了。这样写你要把这几个参数传过来,你 直接写在列中。 我定义的combobox, 可是change事件没有被调用阿~~inputFileType = new Ext.form.ComboBox( { id : myid, fieldLabel : colItem.displayName, store : arStore, editable : false, displayOrder : colItem.displayOrder, typeAhead : true, forceSelection : true, triggerAction : "all", emptyText : "", selectOnFocus : true, itemCls : 'required', labelStyle : 'font-weight:bold;' + WWUJ.Fw.Comp .getLabelStyle(WWUJ.Fw.Const.EDITCD_REQUIRED), width : 260, listeners : { 'select' : function(obj, value) { ... }, 'change': function (c) { c.getEl().dom.style.color = c.value; alert(c.value); } } }); 而且style设定的颜色,是选完之后的字体颜色,~ 我想设定的是,点击选择下拉框时,所有项目,根据条件不同,显示出不同的颜色~ this.tf_customer_level_color = new Ext.form.ComboBox({// 定义组合框中显示的数据源 xtype : 'combo', mode : 'local', triggerAction : 'all', forceSelection : true, fieldLabel : '选择颜色', labelStyle : 'text-align:right', width : 200, store : new Ext.data.SimpleStore({ fields : ['value', 'customer_level_color'], // data : [['value','<div style="background-color:'+ 'value"' + '> </div>']] data : [['white', '<div style="background-color:white"> </div>'], ['red', '<div style="background-color:red"> </div>'], ['green', '<div style="background-color:green"> </div>'], ['blue', '<div style="background-color:blue"> </div>'], ['yellow', '<div style="background-color:yellow"> </div>'], ['purple', '<div style="background-color:purple"> </div>'], ['pink', '<div style="background-color:pink"> </div>'], ['slateblue', '<div style="background-color:slateblue"> </div>'], ['saddlebrown', '<div style="background-color:saddlebrown"> </div>'], ['slategray', '<div style="background-color:slategray"> </div>'], ['yellowgreen', '<div style="background-color:yellowgreen"> </div>'], ['navy', '<div style="background-color:navy"> </div>'], ['brown', '<div style="background-color:brown"> </div>']] }), valueField : 'value', displayField : 'customer_level_color', allowBlank : false, value : '', name : 'customer_level_color' }); 有谁jqueryMobile用的很好呀?急救啊 请问下如何将图片设置为type为text的背景图片呢? 分页问题 xmlhttp在读取网页时防止死界面 一个javascript的小问题,求高手指点!!! 怎么获得div的大小? 请问如何实现下载时不提示对话框? 你们都用过什么方式引入js,css等资源文件的呢? 请教关于input框赋值的问题 关于父-子窗口的问题,请高手指教! 求一个比较完整的Dojo项目java版的 extjs-怎么清空树
grid.render=function(data, metadata, record, rowIndex, columnIndex, store) {
if(条件){
//这里可以根据rowIndex,columnIndex 设置字体颜色
return '<span style="color:red;"><B>' + record.data["Number"] + '</B></span>';
} else {
return record.data["Number"];
}
}
但是执行的时候后面的四个参数都是null,~
不知道是不是我上面的代码抄的不对~~~
combo用同样方法应该也可以实现颜色的设置吧?
var s = new Ext.form.ComboBox({
renderTo: Ext.getBody(),
mode: 'local',
editable:false,
width: 120,
triggerAction: 'all',
displayField:'displayText',
valueField: 'value',
store: new Ext.data.SimpleStore({
fields : ['displayText','value' ],
data : [[ '红','red'], ['蓝', 'blue']]
}),
listeners: {
change: function (c) {
c.getEl().dom.style.color = c.value;
//在这个事件中做其他的操作,如改变颜色
}
}
});
cm:[{
header: 'head',
dataIndex: "tou",
renderer: function(data, metadata, record, rowIndex, columnIndex, store) {
if(条件){
....
}]
写成这样肯定后面的参数都null了。这样写你要把这几个参数传过来,你 直接写在列中。
id : myid,
fieldLabel : colItem.displayName,
store : arStore,
editable : false,
displayOrder : colItem.displayOrder,
typeAhead : true,
forceSelection : true,
triggerAction : "all",
emptyText : "",
selectOnFocus : true,
itemCls : 'required',
labelStyle : 'font-weight:bold;' + WWUJ.Fw.Comp
.getLabelStyle(WWUJ.Fw.Const.EDITCD_REQUIRED),
width : 260,
listeners : {
'select' : function(obj, value) {
... },
'change': function (c) {
c.getEl().dom.style.color = c.value;
alert(c.value);
} } });
我想设定的是,点击选择下拉框时,所有项目,根据条件不同,显示出不同的颜色~
xtype : 'combo',
mode : 'local',
triggerAction : 'all',
forceSelection : true,
fieldLabel : '选择颜色',
labelStyle : 'text-align:right',
width : 200,
store : new Ext.data.SimpleStore({
fields : ['value', 'customer_level_color'],
// data : [['value','<div style="background-color:'+ 'value"' + '> </div>']]
data : [['white', '<div style="background-color:white"> </div>'],
['red', '<div style="background-color:red"> </div>'],
['green', '<div style="background-color:green"> </div>'],
['blue', '<div style="background-color:blue"> </div>'],
['yellow', '<div style="background-color:yellow"> </div>'],
['purple', '<div style="background-color:purple"> </div>'],
['pink', '<div style="background-color:pink"> </div>'],
['slateblue', '<div style="background-color:slateblue"> </div>'],
['saddlebrown', '<div style="background-color:saddlebrown"> </div>'],
['slategray', '<div style="background-color:slategray"> </div>'],
['yellowgreen', '<div style="background-color:yellowgreen"> </div>'],
['navy', '<div style="background-color:navy"> </div>'],
['brown', '<div style="background-color:brown"> </div>']]
}),
valueField : 'value',
displayField : 'customer_level_color',
allowBlank : false,
value : '',
name : 'customer_level_color'
});