How setting format date on a datepicker in a editable grid?

667 views
Skip to first unread message

Cesar Lopez

unread,
Jun 14, 2012, 9:36:19 AM6/14/12
to struts2-jquery
Hi!

I have a editable grid with a editable column with datepicker:

JAVASCRIPT:
<script type="text/javascript">
jQuery.struts2_jquery.require( [ "js/base/jquery.ui.widget" +
jQuery.struts2_jquery.minSuffix + ".js", "js/base/
jquery.ui.datepicker" + jQuery.struts2_jquery.minSuffix + ".js" ]);
if (jQuery.struts2_jquery.local != "en")
{
jQuery.struts2_jquery.require("i18n/jquery.ui.datepicker-" +
jQuery.struts2_jquery.local + ".min.js");
}
var datePick = function(elem)
{
jQuery(elem).datepicker();
jQuery('#ui-datepicker-div').css("z-index", 2000);

}
</script>

GRIDCOLUMN:
<sjg:gridColumn
name="fechaIni"
index="fechaIni"
title="Fecha propuesta"
sortable="false"
width="115"
editable="true"
formatter="date"
formatoptions="{newformat : 'd-m-Y', srcformat : 'Y-m-d H:i:s'}"
editoptions="{dataInit:datePick}"
/>

I WANT CHANGING DATEPICKER DEAULT FORMAT (mm/dd/yyyy) to (dd/mm/yyyy)
in edit mode, but I don't know how doing it.

I tried change the script line jQuery(elem).datepicker(). to:
jQuery(elem).datepicker().displayFormat="dd/mm/yy"
but didn't woks.

Somebody Knows how to do it?

Regards

Alexandre Bizeau

unread,
Jun 14, 2012, 10:42:59 AM6/14/12
to struts2...@googlegroups.com
Hello cesar,

When you edit, you want to use : editrule ( That the format validation when you enter a date on edit) and edittype to date and after into the edittype, you can set the formatoptions i think. Because the formatoptions on a gridColumn just change the display when not edited. Just read information on gridColumn tags there : http://code.google.com/p/struts2-jquery/wiki/GridColumnTag


Maybe the editoptions can be a solution too but i'm not sure. With something like that :

editoptions: {
      size
: 10, maxlengh: 10,
      dataInit
: function(element) {
        $
(element).datepicker({dateFormat: 'yy.mm.dd'})
     
}




2012/6/14 Cesar Lopez <cesar....@gmail.com>

--
You received this message because you are subscribed to the Google Groups "struts2-jquery" group.
To post to this group, send email to struts2...@googlegroups.com.
To unsubscribe from this group, send email to struts2-jquer...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/struts2-jquery?hl=en.


Cesar Lopez

unread,
Jun 14, 2012, 12:34:08 PM6/14/12
to struts2-jquery
Hellow Alexandre!

I follow your suggestion and put the $
(element).datepicker({dateFormat: 'dd-mm-yy'})
in my script a all works OK.

Really Thank you so much for all help. :)

Regards!!!



On Jun 14, 9:42 am, Alexandre Bizeau <alexandrebiz...@gmail.com>
wrote:
> Hello cesar,
>
> When you edit, you want to use : editrule ( That the format validation when
> you enter a date on edit) and edittype to date and after into the edittype,
> you can set the formatoptions i think. Because the formatoptions on a
> gridColumn just change the display when not edited. Just read information
> on gridColumn tags there :http://code.google.com/p/struts2-jquery/wiki/GridColumnTag
>
> Maybe the editoptions can be a solution too but i'm not sure. With
> something like that :
>
> editoptions: {
>       size: 10, maxlengh: 10,
>       dataInit: function(element) {
>         $(element).datepicker({dateFormat: 'yy.mm.dd'})
>       }
>
> 2012/6/14 Cesar Lopez <cesar.lop...@gmail.com>

Alexandre Bizeau

unread,
Jun 14, 2012, 1:01:41 PM6/14/12
to struts2...@googlegroups.com
No problem ! I'm using a lot of grid/autocompleter in my webapp and I saw a lot issues and I did a lot of custom and sometime, it's work on first time and sometime not.

So when i can help some one to skip every time I pass on something usefull but not ordinary, I'm there to answer ! But Johannes still the best one to give you answer :P

Have a nice day !

Alex

2012/6/14 Cesar Lopez <cesar....@gmail.com>
Reply all
Reply to author
Forward
0 new messages