Skip to content

Instantly share code, notes, and snippets.

@kikously
Created February 16, 2021 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kikously/da08ac1cdee191c6fecda4c13ebdad11 to your computer and use it in GitHub Desktop.
Save kikously/da08ac1cdee191c6fecda4c13ebdad11 to your computer and use it in GitHub Desktop.
Edit type of a column depending on conditions
$col = array();
$col["title"] = "typeVal";
$col["name"] = "type_value"; // VALUE =  LIST OR TEXT
$col["dbname"] ="cat_attributs.type_value";
$col["editable"] = false;
$col["hidden"] = true;
$cols[] = $col1;
$col= array();
$col["title"] = "Value";
$col["name"] = "value";
$col["dbname"] ="products_references_attributs.value";
$col["width"] = "50";
$col["search"] = true;
$col["editable"] = true; 
if($row["type_value"] == "LIST"){
$col["edittype"] = "select"; // render as select
$str = $grid->get_dropdown_values("SELECT DISTINCT cat_attributs_value.value as k ,cat_attributs_value.value as v FROM cat_attributs_value INNER JOIN cat_attributs ON cat_attributs.value_code = cat_attributs_value.value_code ");
$col["editoptions"] = array("value"=>$str);
$col["editoptions"]["onload"]["sql"] ="SELECT DISTINCT cat_attributs_value.value as k ,cat_attributs_value.value as v FROM cat_attributs_value INNER JOIN cat_attributs ON cat_attributs.value_code = cat_attributs_value.value_code WHERE cat_attributs.cle = '{cle}'";
$col["stype"] = "select";
$col["searchoptions"] = array("value" => $str);
}
else{
$col["edittype"] ="text";
}
$col1s[] = $col1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment