EXTJS日期字段问题,请帮忙
|
我在尝试弄清楚这是怎么回事时遇到了麻烦。我从回调中使用Extjs和AJAX与JsonStore一起使用,我在ASP中的页面调用数据库并返回此字段中的某些字段,其中存在一个Date,并且此日期返回正确的日期,例如:\“ date_creat_post \”:\“ 29 \\ u002F04 \\ u002F2011 \“ ...
现在,一旦我在datagrid的页面中查看了我的输出,就会得到以下信息:
04/05/2013 <---->它在回调中返回的日期是04/05/2011
06/05/2012 <---->它在回调中返回的日期是06/05/2010
2012年7月4日<---->它在回调中返回的日期是07/04/2010
我看了所有的代码,看看它们是否是我要向日期添加1年的地方。
但找不到。我已经尝试了至少2天,以解决此问题。
这是我的代码:
Ext.onReady(function(){
Ext.QuickTips.init();
// for this demo configure local and remote urls for demo purposes
var url = {
local: \'\', // static data file
remote: \'../myurl.asp\'
};
// configure whether filter query is encoded or not (initially)
var encode = true;
// configure whether filtering is performed locally or remotely (initially)
var local = false;
var PostStore = new Ext.data.JsonStore({
// store configs
autoDestroy: true,
baseParams : {filter : \'[{\"type\":\"boolean\",\"value\":false,\"field\":\"is_sent_post\"}]\'},// we start only with is_sent == false
url: url.remote,
remoteSort: false,
sortInfo: {
field: \'date_creat_post\',
direction: \'DESC\'
},
storeId: \'Post_Store\',
// reader configs
idProperty: \'id_post\',
root: \'Post\',
totalProperty: \'totalcount\',
fields: [{
name: \'id_post\',
type: \'number\'
}, {
name: \'name_post\',
type: \'string\'
}, {
name: \'date_creat_post\',
type: \'date\'//,
//dateFormat: \'Y-m-d H:i:s\'
}, {
name: \'from_addr_post\',
type: \'string\'
}, {
name: \'sender_name_post\',
type: \'string\'
}, {
name: \'is_sent_post\',
type: \'boolean\'
}, {
name: \'date_sending_post\',
type: \'date\'//,
//dateFormat: \'Y-m-d H:i:s\'
}, {
name: \'html_post\',
type: \'string\'
}, {
name: \'list_send_post\',
type: \'number\'
}],
writer: new Ext.data.JsonWriter({
writeAllFields: true
}),
autoSave: false,
batch: true
});
var filters = new Ext.ux.grid.GridFilters({
// encode and local configuration options defined previously for easier reuse
encode: encode, // json encode the filter query
local: local, // defaults to false (remote filtering)
filters: [{
type: \'numeric\',
dataIndex: \'id_post\'
}, {
type: \'string\',
dataIndex: \'name_post\'
}, {
type: \'date\',
dataIndex: \'date_creat_post\'
}, {
type: \'string\',
dataIndex: \'from_addr_post\'
}, {
type: \'string\',
dataIndex: \'sender_name_post\'
}, {
type: \'boolean\',
dataIndex: \'is_sent_post\'
}, {
type: \'date\',
dataIndex: \'date_sending_post\'
}, {
type: \'string\',
dataIndex: \'html_post\'
}, {
type: \'numeric\',
dataIndex: \'list_send_post\'
}]
});
// use a factory method to reduce code while demonstrating
// that the GridFilter plugin may be configured with or without
// the filter types (the filters may be specified on the column model
var createColModel = function (finish, start) {
var columns = [{
dataIndex: \'id_post\',
hidden:true,
header: \'Id\',
// instead of specifying filter config just specify filterable=true
// to use store\'s field\'s type property (if type property not
// explicitly specified in store config it will be \'auto\' which
// GridFilters will assume to be \'StringFilter\'
filterable: true
//,filter: {type: \'numeric\'}
}, {
dataIndex: \'name_post\',
header: \'Subject\',
width: 150,
id: \'postname\',
filter: {
type: \'string\'
// specify disabled to disable the filter menu
//, disabled: true
}
}, {
dataIndex: \'date_creat_post\',
header: \'Date Created\',
renderer: Ext.util.Format.dateRenderer(\'d/m/Y\'),
filter: {
type: \'date\' // specify type here or in store fields config
}
}, {
dataIndex: \'from_addr_post\',
header: \'From Address\',
hidden:true,
id: \'fromaddress\',
filter: {
type: \'string\'
// specify disabled to disable the filter menu
//, disabled: true
}
}, {
dataIndex: \'sender_name_post\',
header: \'Sender Name\',
id: \'sendername\',
filter: {
type: \'string\'
// specify disabled to disable the filter menu
//, disabled: true
}
}, {
dataIndex: \'is_sent_post\',
header: \'Status\',
filter: {
type: \'boolean\' // specify type here or in store fields config
},
renderer: function(value) {
var rtn = (value == 1) ? \'sent\' : \'stand-by\';
return rtn
}
}, {
dataIndex: \'date_sending_post\',
header: \'Sending Date\',
hidden:true,
//renderer: Ext.util.Format.dateRenderer(\'d/m/Y\'),
filter: {
type: \'date\' // specify type here or in store fields config
}
}, {
dataIndex: \'list_send_post\',
header: \'Opticians list\',
hidden:true,
id: \'optlist\',
filter: {
type: \'number\'
// specify disabled to disable the filter menu
//, disabled: true
}
}];
return new Ext.grid.ColumnModel({
columns: columns.slice(start || 0, finish),
defaults: {
sortable: true
}
});
};
/*
//======================contextMenu triggered by right click========================================
*/
var doRowCtxMenu = function ( thisGrid, rowIndex,cellIndex, evtObj )
{
//Ext.popup.msg(\'Done !\', \'Right clicked !\');
evtObj.stopEvent();
var sm = thisGrid.getSelectionModel();
var records = sm.getSelections(); // returns an array of Ext.data.Records
try
{
//var r = records[0]; // get the 1st Ext.data.Record of the list
thisGrid.rowCtxMenu = new Ext.menu.Menu({
items: [{
text : \'<span style=\"color:red;\">Delete Selected Email ?</span>\',
handler : function () {
deletePost(records,thisGrid);
}
}]
});
thisGrid.rowCtxMenu.showAt(evtObj.getXY());
}
catch(err)
{
Ext.popup.msg(\'Warning !\', \'You need to select a row first !\');
}
};
/*
//======================END contextMenu triggered by right click========================================
//======================Delete Post Fonction =================================================
*/
function deletePost(records,thisGrid)
{
Ext.Msg.show({
title :\'Warning !\',
msg : \'You are about to delete 1 email !\',
buttons : Ext.Msg.YESNOCANCEL,
fn : function(btn){
if (btn==\'yes\')
{
var store = thisGrid.getStore();
var s = thisGrid.getSelectionModel().getSelections();
for(var i = 0, r; r = s[i]; i++){
store.remove(r);
}
store.proxy.conn.url = \'../myurl.asp\';
store.save();
lastOptions = store.lastOptions;
/*Ext.apply(lastOptions.params, {
//myNewParam: true
});*/
store.load(lastOptions);
}
},
animEl : \'elId\'
});
}
/*
//======================End delete Function========================================
*/
var Postgrid = new Ext.grid.GridPanel({
id:\'post_grid\',
border: false,
width: 462,
height:250,
store: PostStore,
colModel: createColModel(8),
loadMask: true,
viewConfig:{
emptyText:\'No Post to display, change/clear your filters, refresh the grid or add a new Email!\'
},
plugins: [filters],
sm: new Ext.grid.RowSelectionModel({
singleSelect: true,
listeners: {
rowselect: function(sm, row, rec) {
Ext.getCmp(\"post_form\").getForm().loadRecord(rec);
//Ext.getCmp(\"htmlEdit\").setValue(\"sdcdsdcdscsdc\");
}
}
}),
//autoExpandColumn: \'company\',
listeners: {
cellcontextmenu : doRowCtxMenu,
render: {
fn: function(){
PostStore.load({
params: {
start: 0,
limit: 50
}
});
}
}
},
bbar: new Ext.PagingToolbar({
store: PostStore,
pageSize: 50,
plugins: [filters]
})
});
// add some buttons to bottom toolbar just for demonstration purposes
Postgrid.getBottomToolbar().add([
\'->\',
{
text: \'Clear Filter Data\',
handler: function () {
Postgrid.filters.clearFilters();
}
}
]);
var panelGrid = new Ext.Panel({
width : 462,
height : 250,
layout : \'fit\',
renderTo: \'post-grid\',
items: Postgrid
});
});
我将在firebug json中提供回调:
{\"totalcount\":3, \"Post\": [{\"id_post\": 83,\"name_post\": \"ghfgh\",\"date_creat_post\": \"29\\u002F04\\u002F2011\",\"from_addr_post\": \"fgh@sdf.com\",\"sender_name_post\": \"gfh\",\"is_sent_post\": false,\"date_sending_post\": \"29\\u002F04\\u002F2011\",\"html_post\": \"<p>dfgdgdgd<\\u002Fp>\",\"list_send_post\": null},{\"id_post\": 61,\"name_post\": \"thomas test\",\"date_creat_post\": \"28\\u002F07\\u002F2010\",\"from_addr_post\": \"\",\"sender_name_post\": \"\",\"is_sent_post\": false,\"date_sending_post\": \"28\\u002F07\\u002F2010\",\"html_post\": \"<p>test test test ets<\\u002Fp>\",\"list_send_post\": null},{\"id_post\": 59,\"name_post\": \"kevin test\",\"date_creat_post\": \"29\\u002F06\\u002F2010\",\"from_addr_post\": \"kevin@art-systems.net\",\"sender_name_post\": \"kevin@art-systems.net\",\"is_sent_post\": false,\"date_sending_post\": \"29\\u002F06\\u002F2010\",\"html_post\": \"<p>jkljljoi ioijiio ijiojio oijio joijoi<\\u002Fp>\\u000A<p> <\\u002Fp>\\u000A<p><span style=\\u0022background-color: #ffffff;\\u0022>igiuihhuhi<\\u002Fspan><\\u002Fp>\",\"list_send_post\": null}]}
在此先感谢,我希望邪恶的网络上的某些人能对我有所帮助。
干杯。
所以在尝试了许多解决方案后我就来解决这个问题
经过多次尝试格式化并插入我的msSQL数据库中的日期示例
这个问题就是问题:13 \\ 09 \\ 2011(d / m / Y)变成了这个09/01/2012(d / m / Y),所以由于某种原因将月份13添加到了月份,所以说13个月不存在,因此日期将为2012年9月1日。
再次查看之后,它的格式似乎还没确定,所以我将其更改为de(m / d / Y),而当我在(extjs)中的datefield上击中13天时,我立即收到了SQL错误。
\“将varchar数据类型转换为日期时间数据类型导致超出范围的值。”
并不断有人现在有任何想法吗???
没有找到相关结果
已邀请:
1 个回复
稍惮
然后是您的
的函数: