Tuesday, December 29, 2009

Dynamic updates to ComboBox in Griffon

Ok, I've been trying to update a ComboBox in a Griffon app using the bind object on either items or dataModel.  I did get some success using the dataModel (if I bind to items, I get a no properties error when I try to update the model).  However, binding to the dataModel would not update the dropdown box and you had to repaint the frame to get it to display at all.

However, this works, simply set the items property to something in the View
    comboBox(items: ["Select"], id: "combo", ....

Then in the controller, remove all the items (if needed) and add the items
    view.combo.removeAllItems()
    view.combo.addItem("Combo 1")
    view.combo.addItem("Combo 2")

I'm not sure this is very Groovy, but this got me to a working version, which is what I need now.  If there is a better way, feel free to post it.  If I find a better way, I'll make another post.

No comments:

Post a Comment