Hi there, I have a table with 20 columns, 3 of these are date columns, is there any way to format these into UK style without having to include every column?
I can achieve what I need by adding ;
$col = array();
$col["title"] = "DOB"; // caption of column
$col["name"] = "DOB"; // grid column name
$col["formatter"] = "date";
$col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'d/m/Y');
$col["editable"] = true;
$cols[] = $col;
However now the page only outputs that column unless I add all 19 other columns in this style? Is there a way to avoide this?
Kind regards
Gary
Hi again, forgot to add I tried using $g->set_columns($cols,true); under the above code and error returned 'Length of col names <> colmodel!'
// caption of column
$col = array();
$col["title"] = "DOB"; // caption of column
$col["name"] = "DOB"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col["formatter"] = "date";
$col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'d/m/Y');
$col["editable"] = true;
$cols[] = $col;
$g->set_columns($cols,true);
Thank you
If you want to customize any specific column properties, and let other columns be displayed from table definition, you can pass 2nd argument of `set_columns($cols,true)` to `true`.
$col = array();
$col["name"] = "company";
$col["edittype"] = "textarea";
$cols[] = $col;
$g->set_columns($cols,true);
Sorry for the last reply, saw your second update late.
Please make sure $cols is not reused before you use in grid set_columns.
OR just put $cols = array(); before it.
Thanks Abu appreciate your fast response, did it manually on this occasion so will try again on next grid.
Gary
Hi Abu, sorry I am just not getting this, I have tried all combinations but just returns the same error of 'Length of col names <> colmodel!'
Tried;
// show all other columns after single column format
$col = array();
$g->set_columns($cols,true);
$cols[] = $col;
// show all other columns after single column format
$col = array();
$g->set_columns($cols,true);
// show all other columns after single column format
$g->set_columns($cols,true);
$cols[] = $col;
// show all other columns after single column format
$g->set_columns($cols,true);
Any ideas or is there a demo where this occurs so I can compare code?
Thank you