Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs条件日期渲染器_Extjs_Extjs4_Extjs Mvc - Fatal编程技术网

Extjs条件日期渲染器

Extjs条件日期渲染器,extjs,extjs4,extjs-mvc,Extjs,Extjs4,Extjs Mvc,我的应用程序中有一个网格,在字段中显示日期。现在,如果日期在上周,我想以粗体格式显示字段。但有两行显示了我想要的输出。我不明白我的病情哪里出了问题。有人能帮我吗?下面是我的代码: { text: 'Start', dataIndex: 'weekstart', flex: 1, renderer: function(value, metaData){ var day

我的应用程序中有一个网格,在字段中显示日期。现在,如果日期在上周,我想以粗体格式显示字段。但有两行显示了我想要的输出。我不明白我的病情哪里出了问题。有人能帮我吗?下面是我的代码:

{
            text: 'Start',  
            dataIndex: 'weekstart',
            flex: 1,
            renderer: function(value, metaData){
                var day = new Date(value) - 0,
                lastDay = Ext.Date.getLastDateOfMonth(value)-0,
                lastWeek = lastDay - 7;
                console.log('day >>> '+day,'lastDay >>> '+ lastDay, 'lastWeek >>> '+lastWeek);
                    return day >= lastWeek ? '<b>' + Ext.Date.format(value, 'M d, Y') + '</b>' : Ext.Date.format(value, 'M d, Y') ;
            }
        }
{
文本:“开始”,
dataIndex:“weekstart”,
弹性:1,
渲染器:函数(值、元数据){
var日=新日期(值)-0,
lastDay=Ext.Date.getLastDateOfMonth(值)-0,
上周=最后一天-7;
log('day>>>'+day,'lastDay>>'+lastDay,'lastDay>>>'+lastDay,'lastdweek>>'+lastdweek);
返回日期>=上周?''+Ext.Date.format(值'md,Y')+'':Ext.Date.format(值'md,Y');
}
}

您好,我已经完成了它,如下所示:

 {
                text: 'Start',  
                dataIndex: 'weekstart',
                width: 84,
                renderer: function(value, metaData, record, row, col, store, gridView){
                    var day = value.getDate(),
                    lastDay = Ext.Date.getDaysInMonth(value),
                    lastWeek = lastDay - 6;
//                    console.log( 'row >>> '+ row,'   day >>> '+ day,'   lastDay >>> '+ lastDay, '   lastWeek >>> '+ lastWeek );
                        return day >= lastWeek ? '<b>' + Ext.Date.format(value, 'M d, Y') + '</b>' : Ext.Date.format(value, 'M d, Y') ;
                }
            }
{
文本:“开始”,
dataIndex:“weekstart”,
宽度:84,
渲染器:函数(值、元数据、记录、行、列、存储、gridView){
var day=value.getDate(),
lastDay=Ext.Date.getDaysInMonth(值),
上周=最后一天-6;
//console.log('row>>'+row,'day>>'+day,'lastDay>>'+lastDay,'lastDay>>>'+lastDay,'lastdweek>>'+lastdweek);
返回日期>=上周?''+Ext.Date.format(值'md,Y')+'':Ext.Date.format(值'md,Y');
}
}

您的
日期
最后一天
都是时间戳,要做到这一点,您应该在
最后一周
中使用时间戳:
最后一周=最后一天-7*24*3600*1000

无论如何,最好使用
getRowClass
格式化值。 在网格配置中,尝试指定
viewConfig

viewConfig: {
    getRowClass: function(record, rowIndex, rowParams, store){
        var value = record.get('lastChange'),
            day = value.getDate(),
            lastDay = Ext.Date.getDaysInMonth(value),
            lastWeek = lastDay - 6;
        return day >= lastWeek ? 'last-week' : '';
    }
}
在列定义中指定类附加类:
tdCls:“日期列”
,然后您可以在css中格式化列:

.last-week .date-column {
    font-weight: bold;
}​

工作示例:

这是一个比@Sumon-Bappi更好的解决方案+1.