Home › Forums › Guriddo Suito PHP › Formating
hi,
it is possible to format a gridcol and a form field differently?
Hello,
I’m not sure that I understand the question correct.
If you mean that the formatting of the field in grid can be different in form editing the answer is yes . Please let us know what exactly you want to do, so that we can give you the best answer.
Kind Regards,
Will
Guriddo Support Team
exacly. i have to format the grid and form edit field diffrently. to be precise, I would like to format a field in the grid and unformated it in the form field.
Hello,
Sorry that we do not have explain what we want.
Do you use custom formatter or use a predefined one like date, currency and so on.
Can you please post a simple code what you do.
Note that if you use custom formatter you should define your own unformat function to get the raw value in edit.
Kind Regards,
Will
Guriddo Support Team
i will try to explain better.
i have an column with an date in my grid with the following code:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
$grid->setUserDate("Y-m-d"); $grid->setUserTime("Y-m-d"); $grid->datearray = array("terminVon"); $grid->setColProperty('terminID', [ 'label' => 'ID', 'hidden' => true, 'width' => 40, "colmenu" => false, 'editoptions' => [ 'readonly' => true] ]); |
All data is stored in in mysql database. the col with the date ist stored as the standard mysql type ‘date’.
All work fine so far. the date appears as YYYY-MM-DD, the html inputfield (type=”date”) use this format and the database use this format also. But in Germany we have DD.MM.YYYY as notation for date.
So I just want to format the date for the output in the grid in german notation. Otherwise, both in the editform and in the database the date format should be used “raw”.
I hope despite my bad English, I could explain my request.
Hello,
You can try with these settings:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$grid->setUserDate("Y-m-d"); $grid->setUserTime("Y-m-d"); $grid->datearray = array("terminVon"); $grid->setColProperty('terminID', array( 'label' => 'ID', 'width' => 40, "colmenu" => false, 'editoptions' => ['readonly' => true], 'formatter'=>'date', "formatoptions"=>array("srcformat"=>"Y-m-d","newformat"=>"d.m.Y"), "unformat"=>"js:function(v){ return $.jgrid.parseDate.call(this, 'd.m.Y', v, 'Y-m-d') ; }", )); |
And you should ser reloadAfterSubmit to true in add and edit form.
Kind Regards,
Will
Guriddo Support Team
Thanks. That works fine.
But the date fields are still in wrong format if i export to pdf.
Hello,
When using PHP the export to PDF is done at the server using a external library TCPDF.
The problem here is that the date is converted to the user using JavaScript, while the export is done at the server with PHP – so the JavaScript code can not be converted to PHP one.
Instead of this there is a solution of the problem – just change the db user format when export is in action. To do so after setUserDate setUserTime do:
|
1 2 3 4 5 6 |
$grid->setUserDate("Y-m-d"); $grid->setUserTime("Y-m-d"); if($grid->oper == 'pdf') { $grid->setUserDate("d.m.Y"); $grid->setUserTime("d.m.Y"); } |
Kind Regards,
Will
Guriddo Support Team
OK. But it doesnt work for me. See Screenshot https://s14.postimg.org/tpyl5z8rl/screenshot.png
Hello,
In which format do you want to export the date in PDF? I’m little confused.
The format you show us is in German date format.
Kind Regards,
Will
Guriddo Support Team
the classic german notation dd.mm.yyyy.
the format is right in the pdf but the date itself is wrong.
Which version of PHP is used?
Guriddo Support Team
PHP 7.1.9.
so should look like: https://s14.postimg.org/sbasm41fl/screenshot2.png
Hello,
You use maybe a version of Guriddo Suito PHP where this was problem exists in PHP 7.x. In PHP 5.x is fine. The problem is fixed in the upcoming release, which will be published tomorrow.
Be a sure you have active subscription to receive the update
Kind Regards,
Will
Guriddo Support Team
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top