Datetime Format, Auto filter and Search

QuestionsDatetime Format, Auto filter and Search
Marcos Paulo asked 9 years ago

Hi Abu and Community. Please could you help me with 2 simple questions? I've read the examples and other questions about this issue without a solution yet. I've the following code, and it's working, but I need that works with the datetime format d/m/Y H:i:s, including auto filter and search:

$col = array();
$col["title"] = "Data";
$col["name"] = "calldate";
$col["width"] = "15";
$col["align"] = "center";
$col["formatter"] = "datetime";
$col["formatoptions"] = array("srcformat"=>'Y-m-d H:i:s',"newformat"=>'Y/m/d H:i:s',"opts" => array("timeFormat"=>"HH:mm:ss"));
$col["searchoptions"] = array("defaultValue"=>'',"searchhidden" => true, "sopt" => array("gt","lt"));
$cols[] = $col;

$g->select_command = "SELECT uniqueid, calldate FROM cdr";

I've tried things like:

$col["formatoptions"] = array("srcformat"=>'Y-m-d H:i:s',"newformat"=>'d/m/Y H:i:s',"opts" => array("timeFormat"=>"HH:mm:ss")); //Show ok, but do not work with Auto filter and Search

$col["name"] = "datacdr";
$col["dbname"] = "date_format(calldate,'%d/%m/%Y %H:%i:%S')";
$g->select_command = "SELECT uniqueid, date_format(calldate,'%d/%m/%Y %H:%i:%S') as datacdr FROM cdr"; // Do not work

Furthermore, can I show the Datetime picker in another language instead English?, as it's working fine in the grid, with:

<script src="phpgrid/lib/js/jqgrid/js/i18n/grid.locale-pt-br" type="text/javascript"></script>

Thanks for any help.

2 Answers
Abu Ghufran answered 9 years ago

For question #1, following should work. Emailing you updated build and demo.

$col["formatoptions"] = array("srcformat"=>'Y-m-d H:i:s',"newformat"=>'d/m/Y H:i:s',"opts" => array());

For question #2, pasting from faqs.

Q) How to change language of datepicker control (localization)?

Add following code in html head, after downloading and setting lang file path. e.g.

<script src="http://jqueryui.com/resources/demos/datepicker/datepicker-ar.js&quot; type="text/javascript"></script>
<script>
$.datepicker.setDefaults( $.datepicker.regional[ "ar" ] );
</script>

Marcos Paulo answered 9 years ago

Thanks Abu. You are the man! With the new build, I could use datetime, date and time, format, search and auto filter successfully. I downloaded the datepicker-pt-BR.js and added the code at the end of html head, then works fine:

<script src="phpgrid/lib/js/jqgrid/js/i18n/datepicker-pt-BR.js" type="text/javascript"></script>
<script>$.datepicker.setDefaults($.datepicker.regional["pt-BR"]);</script>

I've posted a new question for you. Keep the great work. Tks again.

Your Answer

2 + 11 =

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 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

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

Let us improve this post!

Tell us how we can improve this post?