Sencha/ExtJS-记录[x].set()未保存/设置

Sencha/ ExtJS - records[x].set() not saving/ setting

本文关键字:保存 设置 set ExtJS- 记录 Sencha      更新时间:2023-09-26

我试图在重新格式化日期后修改日期字段。当我尝试将格式化日期设置为记录时,该字段将变为未定义。

这似乎是一个直接的过程,但结果并不像预期的那样。

for (var x = 0; x < count; x++) {
    var formattedDate = Ext.Date.format(records[x].data.date, 'H:i:s');
    console.log('date = ' + formattedDate); // Prints the correct formatted date
    records[x].set('date', formattedDate);
}
store.sync();
for (var x = 0; x < count; x++) {
    console.log(records[x].data.date) // Prints 'undefined'
}

您的字段是什么类型的日期?如果是Date类型,则必须设置Date对象,请记住Ext.Date.format返回的是字符串对象,而不是Date对象。

您应该尝试分配一个日期对象:

myRecord.set('date',myDateObject);