tsfly2010 2010-10-15 00:57 采纳率: 0%
浏览 356
已采纳

ext 中关于一个render的问题

请问下面红色部分有什么问题,没有达到预期的效果

Ext.onReady(function(){
var data=[
{id:1,name:'小王',email:'xiaowang@qq.com',sex:'男',bornDate:'1695-9-4'},
{id:2,name:'小李',email:'xiaoli@qq.com',sex:'女',bornDate:'1963-12-4'},
{id:3,name:'小张',email:'xiaozhang@qq.com',sex:'男',bornDate:'2000-3-8'}
];

var store=new Ext.data.JsonStore({
    data:data,
    fields:["id","name","email","sex",{name:"bornDate",type:"date",dateFormat:"Y-n-j"}]
});

var colM=new Ext.grid.ColumnModel([
    {
        header:"姓名",
        dataIndex:"name",
        align:'center',
        [color=red]render:function(value, cellmeta, record, rowIndex, columnIndex, store){
            if (record.data["name"] == '小王') {return "<span style='color:red;'>xiaowang</span>";}
        },[/color]      sortable:true,//可排序,
    //align:'right',
        editor:new Ext.form.TextField()//可编辑
    },
    {
        header:"性别",
        dataIndex:"sex",
        sortable:true,
        //下拉列表 sexList在下边已定义,lazyRender:true表示不单独显示在下边定义的下拉列表
        editor:new Ext.form.ComboBox({transform:"sexList",triggerAction:"all",lazyRender:true})
    },
    {
        header:"出生日期",
        dataIndex:"bornDate",
        width:120,
        sortable:true,
        renderer:Ext.util.Format.dateRenderer('Y年m月d日'),//日期格式化
        editor:new Ext.form.DateField({format:"Y年m月d日"})
    },
    {
        header:"电子邮件",
        dataIndex:"email",
        sortable:true,
        editor:new Ext.form.TextField()
    }
]);

var grid=new Ext.grid.EditorGridPanel({
    renderTo:"hello",
    title:"学生信息管理系统",
    height:200,
    width:600,
    cm:colM,
    store:store,
    clicksToEdit:1   //单击时可以编辑  默认为双击
});

});

展开全部

  • 写回答

3条回答 默认 最新

  • lizhiyezi 2010-10-15 01:27
    关注

    添加GridPanel 属性,设置每列textalign 对其方式

    view : new Ext.grid.GridView({
    autoFill : true,
    getColumnStyle : function(col, isHeader) {
    var style = !isHeader
    ? (this.cm.config[col].css || '')
    : '';
    style += 'width:' + this.getColumnWidth(col)
    + ';';
    if (this.cm.isHidden(col)) {
    style += 'display:none;';
    }
    if (isHeader) {
    var align = this.cm.config[col].align;
    if (align) {
    style += 'text-align:' + align + ';';
    }
    } else {
    var align = this.cm.config[col].textalign;
    if (align) {
    style += 'text-align:' + align + ';';
    }
    }
    return style;
    }
    })

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部