Created
February 16, 2021 13:30
-
-
Save kikously/da08ac1cdee191c6fecda4c13ebdad11 to your computer and use it in GitHub Desktop.
Edit type of a column depending on conditions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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