PDA

View Full Version : Extend DateField to provide valueFormat



DAddYE
18 Jun 2009, 6:01 AM
HI,

I suggest staff to extend DateField. Why this?

Because php/rails but I think other languages need a format for Display Date(time) and a format for the value.

For example if my format is: 'd/m/y' I can't send it to my server, I need to exend default extjs DateField...

In my opinion is necessary build a unique DateTimeField and when we build the config we can do some like this:



var d = new Ext.form.DateTimeField({
...some defaults...
hideTime: true, // for those that need only date
displayFormat: 'd/m/y',
valueFormat: 'Y-m-d H:i:s' // default format for mysql!!!!
});


What do you think? You can make my life easier!!!

Consider also that now Yea, I can use my own extension, but 1) is a lot of code, 2) need to be recoded according to changes in ext main code!

Many many thanks!

conorarmstrong
18 Jun 2009, 6:06 AM
altFormats & format config options already do that.

Animal
18 Jun 2009, 6:09 AM
No, the OP means a different format for the displayed value of the field, which is the user's view of what a date is, and a different format submitted.

A bit like the hiddenName of ComboBox.

This has been needed for ever. And I requested it when Jack was first creating yui-ext.

I have an extension at work which uses a hidden field to submit an ISO formatted date time string regardless of how the user wants to see his dates (which is soft settable)

conorarmstrong
18 Jun 2009, 6:41 AM
@Animal - yes, you are correct. I always got around this by having my server process dates in the same format as that specified in the format config.

If that wasn't adequate I added a listener to update a hiddenfield.

I initially read the OP's request as an issue with what the server provided and what was displayed as opposed to what was displayed and what was provided upon submission

DAddYE
19 Jun 2009, 12:18 AM
Yes, and in my opinion I don't understand for how is necessary a DateField in this way.

But, what we can do? Any of the "staff" can reply?

Thanks!

DAddYE
19 Jun 2009, 5:58 AM
Updated the subject of this thread

Animal
19 Jun 2009, 6:49 AM
Perhaps you shoud post in the Premium area if you want the dev team to respond.

aconran
19 Jun 2009, 6:52 AM
This looks like a reasoanble suggestion. I am moving it to Feature Requests and we will consider it after 3.0 final.

Thanks,

DAddYE
19 Jun 2009, 6:56 AM
acoran, hehe sorry I just posted in premium section...

but please do that in the final version I spent 2 days for adapt my DateTimeField according to changes of Extjs 3.0 and is not 100% perfect because have some issues of rendering.

Condor
19 Jun 2009, 7:00 AM
Did you know that there already is a heavily used user extension (http://extjs.com/forum/showthread.php?t=25900) for this?

DAddYE
19 Jun 2009, 7:05 AM
Condor, yea and now Im using a custom version of it.

This is a very very useful plugin but... is a plugin so have some trouble, for example, it use a table so is tricky render it inline of some text, then if you use it in a non active tab there are some rendering issues, and final is a lot of code, and ext itself is big ...

I prefer an "official" version, this simply because now DateField in this way is totally unusable, It's always necessary a parsing, then if is necessary TimeField are a lot of work...

Please add it in the final version of Ext 3.0

Animal
19 Jun 2009, 7:17 AM
Did you know that there already is a heavily used user extension (http://extjs.com/forum/showthread.php?t=25900) for this?

What I have in mind is a fully configurable DateTimeField which can take configs



enableDate: true/false,
enableTime: true/false


And display a DateField and TimeField side by side depending on the configs.

The date+time value shoud be maintained in a configurable format in a hidden field.

Like in this screen, the Delivery in input:

http://i131.photobucket.com/albums/p286/TimeTrialAnimal/newbooking.jpg

mystix
19 Jun 2009, 7:17 AM
-1 (to the OP's request)

that's a very short-sighted use case.

i would rather have Ext.form.Action.Submit enhanced to the tune of this ingenius extension:
http://extjs.com/forum/showthread.php?t=28491

(p.s. i vaguely recall a related discussion by either @animal / @condor about some generic form.getValues() method which would allow customised form value collection)

Condor
19 Jun 2009, 7:30 AM
p.s. i vaguely recall a related discussion by either @animal / @condor about some generic form.getValues() method which would allow customised form value collection)

Discussion here (http://www.extjs.com/forum/showthread.php?t=50028) and my current override code here (http://www.extjs.com/forum/showthread.php?p=308186#post308186).

Animal
19 Jun 2009, 7:34 AM
-1 (to the OP's request)

that's a very short-sighted use case.

i would rather have Ext.form.Action.Submit enhanced to the tune of this ingenius extension:
http://extjs.com/forum/showthread.php?t=28491

(p.s. i vaguely recall a related discussion by either @animal / @condor about some generic form.getValues() method which would allow customised form value collection)

I agree in the long term that forms should submit by having their getValue methods polled.

But the major thrust of my request is for a combined DateTimeField.

If for now, the submittable value is in a hidden, then so be it until the collection of fields for submission is changed from a scan of the DOM to a scan of the Fields Collection.

mystix
19 Jun 2009, 7:35 AM
Discussion here (http://www.extjs.com/forum/showthread.php?t=50028) and my current override code here (http://www.extjs.com/forum/showthread.php?p=308186#post308186).

aren't parts of your override already in both the 2.x / 3.x svn (specifically, the recent getName() fixes)? you might want to update that thread with a new post specifying just the additional overrides (against the latest svn revision) which are required.

DAddYE
19 Jun 2009, 7:43 AM
Sorry, but one question, 90% of user (I think) use ExtJs with a database, sql, mysql, sqlite etc... okey? So can any tell me for how is necessary submitting a date according to the display field?

So in this way why build don't apply the same concept to combo? Why we display a value and send another?

Last question, If in my db Ive datetime field? I need to trick code for:

grep the value of datefield
grep the value of timefield

reformat them... I cant send 09/11/1983 11:00 p.m !!! ... lot of code lot of work...

jay@moduscreate.com
19 Jun 2009, 8:21 AM
To hijack,something is definitely wrong with the forums. a 'normal user' can post replies?

aconran
19 Jun 2009, 8:25 AM
To hijack,something is definitely wrong with the forums. a 'normal user' can post replies?

The thread was moved; lets stay on topic; mmmmk?

jay@moduscreate.com
19 Jun 2009, 8:50 AM
ah!. sorry bout that ;)

DAddYE
22 Jun 2009, 4:45 AM
Any news?


Sorry, but one question, 90% of user (I think) use ExtJs with a database, sql, mysql, sqlite etc... okey? So can any tell me for how is necessary submitting a date according to the display field?

So in this way why build don't apply the same concept to combo? Why we display a value and send another?

Last question, If in my db Ive datetime field? I need to trick code for:

grep the value of datefield
grep the value of timefield

reformat them... I cant send 09/11/1983 11:00 p.m !!! ... lot of code lot of work...

evant
22 Jun 2009, 4:50 AM
We'll look at it, but it almost definitely won't make the 3.0 final.

DAddYE
10 Jul 2009, 12:05 AM
Is possible know if this fatures can be included in a next release or not?

Thanks!

Condor
10 Jul 2009, 1:09 AM
A related request:

ComboBox currently has a text input and optionally a hidden input element.
Implementing this request would require adding the same feature to DateField.
Wouldn't it be better to generalize this feature to TriggerField or even Field?

I already use a custom component that extends TriggerField with a hidden input. But there is also a Checkbox extension to allows submitting an unchecked value that could also benefit from this if the feature was added to Field.

Animal
10 Jul 2009, 1:41 AM
And I would suggest doing away with hiddenName

Generate a new name for the visible element, and call the hidden element the requested name.

This keeps tripping people up. They don't seem to be able to see that the name they specify becomes the name of the visible input and submits the displayField's value.

Condor
10 Jul 2009, 2:02 AM
And I would suggest doing away with hiddenName

Generate a new name for the visible element, and call the hidden element the requested name.

This keeps tripping people up. They don't seem to be able to see that the name they specify becomes the name of the visible input and submits the displayField's value.

But that is only relevant for ComboBox.

ComboBox.initComponent should contain:

if(!this.hiddenName && this.valueField){
this.hiddenName = this.name || this.id;
}

For other component (e.g. the TriggerField I mentioned), the presence of a hiddenName should still indicate it should create a hidden field.