Updating a Select field in a Form

Hi again guys!

I’m having problems with on of my Forms. It has a Select field (that is created in FieldFactory.createField). I save a reference to that Select so that I can refresh its contents (removeAllItems, addItem in a loop) after certain events. It seems that the client end still shows the original contents after that.

Any ideas what I’ve messed up? Should I build the whole form again?

I think it is ok to call functions like this. What i would probably do is to use the form.getField method to find the Select whenever needed instead of storing it, but that should not make any difference.

The FieldFactory is used to create field to form when new data source is set to the Select. So, basically what could be causing this is that the data source is reset after calling the removeItems/addItem loop. Otherwise, I can’t really see why the updates don’t show…

Problem solved. Man, this was a b*tch…

There were actually two problems:

The first was that FieldFactory.createField was called twice: first at form.setItemDataSource and secondly at form.setVisibleItemProperties. I fixed this using an internal flag that I raise after setItemDataSource. Maybe it would have worked too, if I first had set the data source, then the field factory and lastly the visible items.

The second and main problem was that I by accident used the same fieldfactory instance with two different forms. And because of that my refresh calls went to a wrong form (that had the data to be updated hidden).

Nice to hear you solved this!

I remembered that there is also a setItemDataSource method that the ids along with it:


That would have probably solves the first issue too.

Oh I see… Must be a new method; don’t remember seen it in 5.4 (that’s the version I used when originally implementing this) :slight_smile: