Hello Abu. I have this situation: i fill a dropdown list in a grid (that is associated to a table "A" in the database) with values that are in a table "B". So when the user select a value in the dropdown list another fiels of that record in the grid update with values that are associated to the select value in the table "B". Up here everything works fine. Now i need to have this behavior but instead of use a dropdown list i want to use a combobox. So i can add new values in the field of the table A and not only does that are in the table B. How i do that?
Here is my code:
// Indico propiedades de la columna "predefinidos".
$col = array();
$col["name"] = "predefinido";
$col["title"] = "Predefinidos";
$col["resizable"] = true;
$col["edittype"] = "select";
# fetch data from database, with alias k for key, v for value
$str = $g->get_dropdown_values("select distinct tarea_predefinida as k, tarea_predefinida as v from tareas_predefinidas");
$col["editoptions"] = array
(
"value"=>$str,
"defaultValue"=>"No",
"onchange" => array
(
"sql"=>"select * from tareas_predefinidas",
"search_on"=>"tarea_predefinida",
"callback" => "fill_form"
)
);
$cols[] = $col;
….
<script>
function fill_form(data)
{
//jQuery("select[name=predefinido].FormElement").val(data[0].tarea_predefinida);
jQuery("select[name=anillado].FormElement").val(data[0].anillado);
jQuery("textarea[name=total].FormElement").val(data[0].total);
//jQuery("select[name=predefinido].editable").val(data[0].tarea_predefinida);
jQuery("select[name=anillado].editable").val(data[0].anillado);
jQuery("textarea[name=total].editable").val(data[0].total);
}
</script>
Thanks for your help.
You can use autocomplete function to achieve this behavior.
Demo: http://phpgrid.org/demo/demos/integrations/autocomplete.php
Code: http://phpgrid.org/demo/demos/integrations/autocomplete.phps
Emailing you latest build.
Hello Abu. I studied the example and i tried to implement it in my code, beside i merge this concept (autocomplete) with master detail grid and the model of my database is not so simple as the one you use in the example; i use tables with relations many to many. I want to use autocomplete to add more records to the table that implement the relation with tow entities but there is where autocomplete fails. Can i email you my code?. Thanks.
Please email me at [email protected].
If you can send sample sql dump, it would help in generating exact case.