tsfly2010 2010-10-15 08: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 09: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条)

报告相同问题?

悬赏问题

  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型