存储中的日期格式

问题描述 投票:0回答:1

如何格式化存储数据,以我的情况为返回日期,并将其绑定到Comobox

var comboDate = new Ext.form.ComboBox({
displayField: 'date',
valueField: 'date',
store: {
    type: 'webapi',
    autoLoad: true,        
    api: {
        read: 'api/Report/GetDate'
    }        
}
});

将其绑定为“ EDT 2016年5月9日星期一00:00:00”

我尝试了几件事来解决它-

 dateFormat: 'c'

   renderer: Utility.Formatting.ShortDateTime

请建议我如何在商店中应用日期格式

UPDATING我在这里添加完整的代码-我试图将日期绑定到网格中的组合框。

 header: 'From Date', dataIndex: 'date',  editor: comboDate, renderer: comboBoxDateRenderer(comboDate)
 var comboBoxDateRenderer = function (comboDate) {
return function (value) {       
    var idx = comboDate.store.find(comboDate.valueField, value);//Ext.util.Format.date(value, "Y-m-d")
    var rec = comboDate.store.getAt(idx);
    return (rec === null ? '' : rec.get(comboDate.displayField));
};
    }

var comboDate = new Ext.form.ComboBox({
displayField: 'date',
valueField: 'date',
//dateFormat: 'c',
store: {
    type: 'webapi',
    autoLoad: true,
    fields: [
          { name: 'date', type: 'date', dateFormat: 'c' }
    ],
    api: {
        read: 'api/Report/GetDate'
    }        
}
});
extjs extjs5
1个回答
0
投票

该值为标准日期对象。您可以使用XTemplates格式化显示字段:https://fiddle.sencha.com/#fiddle/1a37

列表模板:

tpl: Ext.XTemplate(
    '<tpl for=".">'+
    '<div class="x-boundlist-item">' +
    '{[Ext.util.Format.date(values.date, "d/m/y")]}' +
    '</div>'+
    '</tpl>'
),

显示字段模板:

displayTpl: Ext.XTemplate(
    '<tpl for=".">'+
    '{[Ext.util.Format.date(values.date, "d/m/y")]}'+
    '</tpl>'
),

请记住,这仅仅是显示输出的纯格式。

© www.soinside.com 2019 - 2024. All rights reserved.