-
20 Apr 2010 4:17 AM #1
daterender in xgcolumnmodel problem NaN/NaN/NaN
daterender in xgcolumnmodel problem NaN/NaN/NaN
Hello all,
I'm new on this forum so please help me. I try to use daterenderer in a columnmodel but when I read the date from the server i allways get NaN/NaN/NaN.
Here is my code.
If you need somethig more please tell me.
How can I see a valid date. To edit or to sane a new date is working.
I have only problems to display it. I read some other posts but i couldn't find a solution to my problem.
Thanks,
[IMG]file:///C:/DOCUME%7E1/admin/LOCALS%7E1/Temp/moz-screenshot-5.png[/IMG]screen1.JPGPHP Code:var cm=new xg.ColumnModel([
{
dataIndex:'id_incident',
hidden:true, defaultValue:ID_INCIDENT,
hideable:false
},{
header: "User", dataIndex: 'user_fullname',
searchable:true, sortable: true, align:'center', width:100, fixed: true,
defaultValue:LOGGED_USER.user_fullname,
hiddenId:'id_user',
hiddenValue:LOGGED_USER.id_user
},{
header: "Equipment", dataIndex: 'equip_name',
searchable:true, width:420,
defaultValue:'Add equipment',
err:'Select equipment !',
editor: new Ext.form.Equip({name: 'id_equip',displayField:'equip_name',allowBlank:false}),
hiddenId:'id_equip'
},{
header: "Whats wrong", dataIndex: 'equip_defect',
searchable:true, width:420,
defaultValue:'Whats wrong',
editor: new Ext.form.TextField({allowBlank: false,maxLength:100})
},{
header: "Serial n.", dataIndex: 'equip_serial',
searchable:true, sortable: true, width:120, fixed: true, align: 'center',
defaultValue:"N/A",
editor: new Ext.form.TextField({allowBlank: false,maxLength:50})
},{
dataIndex: 'equip_sent_date', id: 'quip_sent_date',header: 'Date', width: 300,
renderer: Ext.util.Format.dateRenderer('d/m/Y'),
editor: new Ext.form.DateField({format: 'd/m/Y'}),
sortable: true
}
]);
store['equip'+ID_INCIDENT] = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'data.php?mode=load_form&form=incident_equip'}),
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'count',
id: 'id_incident_equip'
},[{name:'equip_sent_date', type:'date'},'id_incident_equip','id_incident','id_user','id_equip','equip_name','equip_serial','incident_equip_date','equip_defect']),
sortInfo:{field:'incident_equip_date', direction:'ASC'}
});
-
20 Apr 2010 5:13 AM #2
Did you set dateFormat in your store's field configuration, so Ext knows what it is getting "coming in", so it can then render it "going out"?
-
20 Apr 2010 11:39 AM #3
I had the same problem
I had the same problem
You have to define the dateFormat in data JsonStore
fields: [ {name:'date', type: 'date', dateFormat: 'Y-m-d H:i
'}]
The date that come in is "2011-11-20 00:00:00" in my program. You have to define the same format .
-
20 Apr 2010 11:19 PM #4
PHP Code:if($_GET['form']=="incident_equip")
{ //@@@@@@@@
$data['fields']="*,
IF(equip_sent_date,UNIX_TIMESTAMP(equip_sent_date),'') as equip_sent_date,
UNIX_TIMESTAMP(incident_equip_date) as incident_equip_date";
$data['tables'].=",user,equip";
$data['conditions']="incident_equip.id_user=user.id_user and incident_equip.id_equip=equip.id_equip";
}
-
20 Apr 2010 11:22 PM #5
-
21 Apr 2010 7:54 AM #6
Show your JSON output.
-
21 Apr 2010 8:38 AM #7
use this function in render
Code:column: { dataIndex: 'equip_sent_date', id: 'quip_sent_date',header: 'Date', width: 300, renderer: renderDate , editor: new Ext.form.DateField({format: 'd/m/Y'}), sortable: true } // Function renderDate = function (v,params,record) { var dt = new Date(v); return dt.format('d/m/Y'); }
-
21 Apr 2010 9:59 AM #8
Hello all,
Thank you for the your help this far.
My problem stillpersists but somehow is different now.
I will explain:
The renderer:PHP Code:if($_GET['form']=="incident_equip")
{ $data['fields']="*,
IF(equip_sent_date,UNIX_TIMESTAMP(equip_sent_date),'') as equip_sent_date,
UNIX_TIMESTAMP(incident_equip_date) as incident_equip_date";
$data['tables'].=",user,equip";
$data['conditions']="incident_equip.id_user=user.id_user and incident_equip.id_equip=equip.id_equip";
}
and the xgColumnPHP Code:datestamp:function(value) {
value=value?new Date( value*1000 ).format("d-m-Y"):'N/A';
return value; }
The renderer i use it from some examples that i find on the internet.PHP Code:{
dataIndex: 'equip_sent_date', id: 'equip_sent_date',header: 'Date', width: 300,
renderer: renderers.datestamp,
editor: new Ext.form.DateField({format: 'd/m/Y'}),
sortable: true
}
The problem now is that it displays all the informations correctly but when i try to edit it doesn't work.
Please help:
I attached some printscreens:
1. It displays the dates correctly:
img1.JPG
2. It displays the datepicker when i want to select/or edit a date:
img2.JPG
3. I selected the date but after I edit it it doesn't display it correctly:
img3.JPG
It is saving the correct date informations in the data base and display it correctly the next time you load it.
Any suggestions ?
-
21 Apr 2010 11:54 PM #9
hello
why you multiplied the value of the date by 1000 (value * 1000)?
I tested your code and everything works
-
22 Apr 2010 1:42 AM #10
If i don't multiplied by 1000 i don't get the date correctly.
img4.JPG
I really don't know what to do and where to check what is wrong.


Reply With Quote