DatePicker – Change default date

QuestionsDatePicker – Change default date
Gaëtan asked 3 years ago

Hi Abu,

I am tried to figure out how to change the default date of a DatePicker.

I have tried "DefaultDate" option but no effects.

Here is the bare code:

$col = array();
$col["title"] = "FWUP";
$col["name"] = "follow_up_date";
$col["width"] = "20";
$col["align"] = "center";
$col["editable"] = true; // this column is editable
$col["editoptions"] = array("size"=>20); // with default display of textbox with size 20
$col["editrules"] = array("required"=>false, "edithidden"=>true); // and is required
# format as date
$col["formatter"] = "date";
# opts array can have these options: http://api.jqueryui.com/datepicker/
$col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'d.m.y', "opts" => array("changeYear" => true, "dateFormat"=>'yy-mm-dd', "minDate"=>"16-04-01"));

$cols[] = $col;

Thanks

3 Answers
Abu Ghufran answered 3 years ago

You can set default value of field using defaultValue option:

$col["editoptions"] = array("size"=>20, "defaultValue" => date("m.d.Y"));

The date format should match with datepicker new format.

Abu Ghufran answered 3 years ago

Complete column settings here:

$col = array();
$col["title"] = "Date";
$col["name"] = "invdate";
$col["width"] = "150";
$col["editable"] = true; // this column is editable
$col["editoptions"] = array("size"=>20, "defaultValue" => date("d.m.Y")); // with default display of textbox with size 20
$col["editrules"] = array("required"=>true, "edithidden"=>true); // and is required
# format as date
$col["formatter"] = "date";
# opts array can have these options: http://api.jqueryui.com/datepicker/
$col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'d.m.Y', "opts" => array("changeYear" => true, "dateFormat"=>'dd.mm.yy', "minDate"=>"10.05.16"));

Gaëtan answered 3 years ago

Many thanks Abu, it now works.

Your Answer

17 + 0 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating / 5. Vote count:

We are sorry that this post was not useful for you!

Let us improve this post!