1

平台为 Sencha Touch 2.1.1。我在表单面板中使用 datPicker,如下所示:

        {
            xtype: 'datepickerfield',
            destroyPickerOnHide: true,
            name : 'dateOfEvaluation', 
            label: 'Date of evaluation',
            dateFormat: 'm/d/Y',
            value: new Date(),
            picker: {
                yearFrom: 2013
            }
        },

在我的模型中被保存为日期类型:

        {name: 'dateOfEvaluation', type: 'date'}, 

如果 store 中有一个值,它会通过 itemTpl 通过以下方法呈现:

onSelectSiteGeneral: function(view, index, target, record, event) {
    console.log('Selected a SiteGeneral from the list');
    var siteGeneralForm = Ext.Viewport.down('siteGeneralForm');

    if(!siteGeneralForm){
        siteGeneralForm = Ext.widget('siteGeneralForm');
    }    
    siteGeneralForm.setRecord(record);
    siteGeneralForm.showBy(target);
}

这一切都很好,花花公子。

问题在于没有保存日期的记录。在日期类型的 localStorage 中,null/empty 值似乎为 0,在我上面的表单中显示为“1969 年 12 月 31 日”。我知道我可以编写一个处理程序来将此显示作为当前日期,但我确定如何继续(我不能使用默认值:new Date(),顺便说一句,因为这不适用于数据存储中已有的值被渲染到表单)。我知道我必须将 n 天添加到零才能获得当前日期,但我不确定如何让它在我的表单中重新呈现。

关于如何让第 0 个日期显示为更现实的日期的任何建议,例如当前日期(我要强调的是,在使用上述方法 onSelectSiteGeneral 时,默认日期似乎不起作用)。感恩!

4

0 回答 0