In Grid 4 PHP 2.9 I can customize a column of a displayed table to be rendered as checkbox:
$g = new jqgrid($db_conf);
// ...
$col = array();
$col["name"] = "esonero";
$col["edittype"] = "checkbox";
$col["editoptions"] = array("value"=>"Yes:No");
$col["formatter"] = "checkbox";
$cols[] = $col;
$g->set_columns($cols, true);
it works fine, but I have to duplicate the same code for all the columns I want to render as checkbox, specifying their name.
I want to automatically set these options for all the BOOLEAN columns of my table:
sql = """CREATE TABLE anagrafica_genitori (
id INT NOT NULL AUTO_INCREMENT,
famiglia VARCHAR(255) NOT NULL,
genitore VARCHAR(255) NOT NULL,
esonero BOOL DEFAULT FALSE,
pulizie BOOL DEFAULT TRUE,
cucina BOOL DEFAULT TRUE,
lun BOOL DEFAULT TRUE,
mar BOOL DEFAULT TRUE,
mer BOOL DEFAULT TRUE,
gio BOOL DEFAULT TRUE,
ven BOOL DEFAULT TRUE,
PRIMARY KEY (id)
);"""
How can I achieve this goal without having to know the name of each column?
Since the connection to the database is handled by Grid 4 PHP I would avoid to make another connection to retrieve the information using the INFORMATION_SCHEMA
.
I’m trying to do this using the native functions of Grid 4 PHP – if possible.