Hi,
is it possible to create columns of table with a function as shown below.
I try but it does not.
function create_column($tit,$nam,$wid,$alg)
{
$col = array();
$col["title"] = $tit;
$col["name"] = $nam;
$col["width"] = $wid;
$col["align"] = $alg;
$col["search"] = true;
$cols[] = $col;
}
kolonyarat("Customer","Customer","50","right");
Hi,
is it possible to create columns of table with a function as shown below.
I try but it does not.
function create_column($tit,$nam,$wid,$alg)
{
$col = array();
$col["title"] = $tit;
$col["name"] = $nam;
$col["width"] = $wid;
$col["align"] = $alg;
$col["search"] = true;
$cols[] = $col;
}
create_column("Customer","Customer","50","right");
Yes you can, if you use global vars. e.g.
$cols = array();
function create_column($tit,$nam,$wid,$alg)
{
global $cols;
$col = array();
$col["title"] = $tit;
$col["name"] = $nam;
$col["width"] = $wid;
$col["align"] = $alg;
$col["search"] = true;
$cols[] = $col;
}
now calling create_column("Customer","Customer","50","right"); will store the cols in $cols array.
Finally, you can call
$grid->set_columns($cols); to pass that global variable to grid object.
Hope it helps.