質問

I have jqSuite up and running, everything works great, except when I'm trying to edit a date. The date source format is YYYY-mm-dd (MySQL), and when displaying, I use the following, which works perfectly for displaying.

"formatoptions"=>array("srcformat"=>"Y-m-d","newformat"=>"m/d/Y")

However when I pop up an edit dialog, the datepicker opens as dd/mm/yy (javascript) is in the wrong format, despite initializing the datepicker with the correct format.

$datepicker = <<<DATEPICK
function(el){
    setTimeout(function(){
        jQuery(el).datepicker({dateFormat:'mm/dd/yy'});
    },200);
}
DATEPICK;

...

"editoptions"=>array("dataInit"=>"js:".$datepicker)

Everything except for the format of the datepicker when editing works as intended.

Any ideas?

Thanks!

役に立ちましたか?

解決 2

Call your datepicker() for each input on document load..

Use a class as a hook on your input:

<input class="my-datepicker">

Then call datepicker on elements with that class with your default configuration:

$('.my-datepicker').datepicker({
    dateFormat: 'm/d/Y'
});

When you need a different configuration, use/assign a different class name.

You can also use setDefaults (probably what you're looking for):

$.datepicker.setDefaults({
    dateFormat: 'm/d/Y'
});

他のヒント

Does adding this code work?

$grid->setUserDate("m/d/Y");
$grid->datearray = array("BirthDate");

Where "BirthDate" is the name of your date column. You might also want to try one of the following lines:

$grid->setUserTime("m/d/Y");
$grid->setDatepicker("BirthDate");

For more information see this page in the docs and this example from the demo page.

Try changing the / for a - just to see if that works. At least you know if it's the / or something else causing the problem.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top