Combobox issue (repopulate)
[email protected] (Robertico)
| Newsgroups | php.gtk.general |
|---|---|
| Message-ID | <[email protected]> |
Hi friends.
I have problems repopulating a combobox depends on a previous combobox
selection. I build my form by a loop and in some part it does the next:
## Combobox para Tercero (First Combobox)
}else if($fila == 2)
{
$aTipo =
array("04"=>"Nacional","05"=>"Extranjero","06"=>"Global");
$cajasCampos[$fila] = new GtkComboBox();
$modelo3 = new
GtkListStore(Gtk::TYPE_STRING,Gtk::TYPE_STRING);
$cajasCampos[$fila]->set_model($modelo3);
$cellRenderer = new GtkCellRendererText();
$cajasCampos[$fila]->pack_start($cellRenderer);
$cajasCampos[$fila]->set_attributes($cellRenderer, 'text',
0);
$cajasCampos[$fila]->set_attributes($cellRenderer, 'text',
1);
fillCombobox($modelo3,$aTipo); // easy function that
populate the combo, receives the model and the array elements
$cajasCampos[$fila]->set_active(0);
$cajasCampos[$fila]->connect_simple('changed','cambiaTercero',$cajasCampos[$fila],$modelo4);
// calling the function to repopulate
$tabla->attach($cajasCampos[$fila],1,2,$fila,$fila+1);
## Combobox para Operacion (Second combobox, the one I want to
to change it)
}else if($fila == 3)
{
$aOperacion = array("03"=>"Prestación de Servicios
Profesionales",
"06"=>"Arrendamiento de
Inmuebles",
"85"=>"Otros");
$cajasCampos[$fila] = new GtkComboBox();
$modelo4 = new
GtkListStore(Gtk::TYPE_STRING,Gtk::TYPE_STRING);
$cajasCampos[$fila]->set_model($modelo4);
$cellRenderer = new GtkCellRendererText();
$cajasCampos[$fila]->pack_start($cellRenderer);
$cajasCampos[$fila]->set_attributes($cellRenderer, 'text',
0);
$cajasCampos[$fila]->set_attributes($cellRenderer, 'text',
1);
fillCombobox($modelo4,$aOperacion);
$cajasCampos[$fila]->set_active(0);
$tabla->attach($cajasCampos[$fila],1,2,$fila,$fila+1);
}
Then I have these functions
function fillCombobox($modelo,$arreglo)
{
## Rellenamos el combo con sus datos (Populate the array)
while(list($valor,$texto) = each($arreglo))
{
$modelo->append(array($valor,$texto));
}
}
function cambiaTercero($combo,$modelo) // this function should repopulate
the second combobox
{
$seleccion = $combo->get_model();
$valor = $seleccion->get_value($combo->get_active_iter(),0);
switch ($valor)
{
case '04':
$aNOperacion = array("03"=>"Prestación de
Servicios Profesionales",
"06"=>"Arrendamiento de Inmuebles",
"85"=>"Otros");
break;
case '05':
$aNOperacion = array("03"=>"Prestación de
Servicios Profesionales",
"85"=>"Otros");
break;
case '15':
$aNOperacion = array("03"=>"Prestación de
Servicios Profesionales",
"06"=>"Arrendamiento de Inmuebles",
"85"=>"Otros");
break;
}
$modelo->clear();
fillCombobox($modelo,$aNoperacion);
}
Well, php tell me I'm calling a function clear() on a non-object.
Thanks to all!
--
L.I. Roberto Carlos Bárcenas Adame.
[email protected]
Tel. 57949690 (Recados)
================
("`-''-/").___..--''"`-._
`6_ 6 ) `-. ( ).`-.__.`)
(_Y_.)' ._ ) `._ `. ``-..-'
_..`--'_..-_/ /--'_.' ,'
(il),-'' (li),' ((!.-'
Por mí raza hablará el espíritu...
======================