date.getTime 不是函数 extJS 日期字段列
date.getTime is not a functioin extJS datefield column
在网格中的日期过滤器期间,我收到此错误。
Uncaught TypeError: date.getTime is not a function
at Object.clearTime (ext-all-rtl-debug.js?_dc=1591679946477:6514)
at constructor.convertDateOnly [as _convert] (ext-all-rtl-debug.js?_dc=1591679946477:237750)
at constructor.getCandidateValue (ext-all-rtl-debug.js?_dc=1591679946477:45385)
at constructor.= [as _filterFn] (ext-all-rtl-debug.js?_dc=1591679946477:45406)
at constructor.filter (ext-all-rtl-debug.js?_dc=1591679946477:45222)
at ext-all-rtl-debug.js?_dc=1591679946477:45143
at constructor.onCollectionRefresh (ext-all-rtl-debug.js?_dc=1591679946477:82919)
at constructor.updateSource (ext-all-rtl-debug.js?_dc=1591679946477:83983)
at constructor.setter [as setSource] (ext-all-rtl-debug.js?_dc=1591679946477:11193)
at constructor.onFilterChange (ext-all-rtl-debug.js?_dc=1591679946477:83515)
这是我的 COlumn defeniation。
"dataIndex" : "date",
"text" : " Date",
"minWidth" : 120.0,
"xtype" : "datecolumn",
"renderer" : "renderDate",
"filter" : {
"type" : "date"
}
这里是 renderDate 方法。
renderDate : function(val){
debugger;
val = new Date(val)
val = Ext.Date.format(val,'d-M-Y H:i:s T');
return val;
},
任何人都可以帮助我解决这个问题以及如何解决它。谢谢是进步。
这是我的网格存储:
Ext.define("MyAPp.store.base.GridStore", {
extend: "Ext.data.Store",
alias:"widget.tGridStore",
requires: ["Ext.data.proxy.Rest"],
model: Ext.create('Ext.data.Model', {
fields: [
{ name: 'name', type: 'String' },
]
}),
autoLoad: false,
remoteSort : false,
remoteFilter: false,
proxy: {
type: 'ajax',
url: 'someURLa',
actionMethods:{
read:'POST'
},
reader: {
type: 'json',
rootProperty: "data",
totalProperty: "TotalCount"
}
}
});
问题不在 renderDate
函数中,否则它的函数名称应该显示在堆栈跟踪中。
过滤器的堆栈跟踪提示。问题的原因似乎是您将 date
类型的过滤器应用于支持网格列的商店上的模型字段。所述过滤器要求支持模型字段包含 javascript 日期对象(或 null),而不是(日期可解析的)非空字符串。至少有一条加载到商店的记录在 date
字段中不包含有效的 javascript 日期对象。
您必须确保模型 fields
配置将 date
字段定义为 date
类型,并且您提供正确的 dateFormat
以便日期字符串在加载时被商店正确转换为 javascript 日期对象:
fields: [{
name: "date",
type: "date",
dateFormat: "Y-m-d H:i:s" // whatever the format is in which you expect the date string from the backend
}]
如果该解决方案尝试不能为您解决问题,请post您的 store/model 定义代码和您加载到商店中的数据。
附带说明,datecolumn
允许您提供日期显示格式作为 format
配置,无需自定义渲染器。
简而言之,需要 store/model 字段 (type: "date"
) dateFormat
将您从后端获得的任何日期字符串转换为 javascript 日期对象;过滤器 (type: "date"
) 然后仅适用于 javascript 日期对象;然后最后列 (xtype: "datecolumn"
) format
知道如何将 javascript 日期对象转换回人类可读的格式(这可能并且通常与后端的格式不同传送到 UI).
在网格中的日期过滤器期间,我收到此错误。
Uncaught TypeError: date.getTime is not a function
at Object.clearTime (ext-all-rtl-debug.js?_dc=1591679946477:6514)
at constructor.convertDateOnly [as _convert] (ext-all-rtl-debug.js?_dc=1591679946477:237750)
at constructor.getCandidateValue (ext-all-rtl-debug.js?_dc=1591679946477:45385)
at constructor.= [as _filterFn] (ext-all-rtl-debug.js?_dc=1591679946477:45406)
at constructor.filter (ext-all-rtl-debug.js?_dc=1591679946477:45222)
at ext-all-rtl-debug.js?_dc=1591679946477:45143
at constructor.onCollectionRefresh (ext-all-rtl-debug.js?_dc=1591679946477:82919)
at constructor.updateSource (ext-all-rtl-debug.js?_dc=1591679946477:83983)
at constructor.setter [as setSource] (ext-all-rtl-debug.js?_dc=1591679946477:11193)
at constructor.onFilterChange (ext-all-rtl-debug.js?_dc=1591679946477:83515)
这是我的 COlumn defeniation。
"dataIndex" : "date",
"text" : " Date",
"minWidth" : 120.0,
"xtype" : "datecolumn",
"renderer" : "renderDate",
"filter" : {
"type" : "date"
}
这里是 renderDate 方法。
renderDate : function(val){
debugger;
val = new Date(val)
val = Ext.Date.format(val,'d-M-Y H:i:s T');
return val;
},
任何人都可以帮助我解决这个问题以及如何解决它。谢谢是进步。
这是我的网格存储:
Ext.define("MyAPp.store.base.GridStore", {
extend: "Ext.data.Store",
alias:"widget.tGridStore",
requires: ["Ext.data.proxy.Rest"],
model: Ext.create('Ext.data.Model', {
fields: [
{ name: 'name', type: 'String' },
]
}),
autoLoad: false,
remoteSort : false,
remoteFilter: false,
proxy: {
type: 'ajax',
url: 'someURLa',
actionMethods:{
read:'POST'
},
reader: {
type: 'json',
rootProperty: "data",
totalProperty: "TotalCount"
}
}
});
问题不在 renderDate
函数中,否则它的函数名称应该显示在堆栈跟踪中。
过滤器的堆栈跟踪提示。问题的原因似乎是您将 date
类型的过滤器应用于支持网格列的商店上的模型字段。所述过滤器要求支持模型字段包含 javascript 日期对象(或 null),而不是(日期可解析的)非空字符串。至少有一条加载到商店的记录在 date
字段中不包含有效的 javascript 日期对象。
您必须确保模型 fields
配置将 date
字段定义为 date
类型,并且您提供正确的 dateFormat
以便日期字符串在加载时被商店正确转换为 javascript 日期对象:
fields: [{
name: "date",
type: "date",
dateFormat: "Y-m-d H:i:s" // whatever the format is in which you expect the date string from the backend
}]
如果该解决方案尝试不能为您解决问题,请post您的 store/model 定义代码和您加载到商店中的数据。
附带说明,datecolumn
允许您提供日期显示格式作为 format
配置,无需自定义渲染器。
简而言之,需要 store/model 字段 (type: "date"
) dateFormat
将您从后端获得的任何日期字符串转换为 javascript 日期对象;过滤器 (type: "date"
) 然后仅适用于 javascript 日期对象;然后最后列 (xtype: "datecolumn"
) format
知道如何将 javascript 日期对象转换回人类可读的格式(这可能并且通常与后端的格式不同传送到 UI).