Problem with a dropdown list.

QuestionsProblem with a dropdown list.
Montemaggiore Sebastian asked 9 years ago

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.

3 Answers
Abu Ghufran answered 9 years ago

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.

Montemaggiore Sebastian answered 9 years ago

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.

Abu Ghufran answered 9 years ago

Please email me at [email protected].
If you can send sample sql dump, it would help in generating exact case.

Your Answer

4 + 14 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?