Optiondatasource valuemap not updating

Hi,

I have a ListGrid bound to a datasource. One of the fields is a primarykey to another datasource. I have set up optiondatasource and it all works as I expect.

When I change displayfield (Name value) in the alternate datasource, the changes are not carried over to valumap of the listgrid. At first I wasn’t sure the changes in the other datasource were being changed, but when I edit the first listgrid, the editor dropdown has the correct valuemap (i.e. the name has changed in the editor dropdown). When I select the value, the non droppeddown version of the editor has the incorrect value.

If I markforredraw the list grid, or change the sort method, or change tabs (The list grid is in a tab panel), the value is still the old one.

Have I forgotten a simple setting?

Thanks.

Edit: Just made a button to run a fetchData on the other datasource, and the value is changed there.

I managed to get this working with the following.

RiskTypeDS.getInstance().fetchData(null, new DSCallback() {
	@Override
	public void execute(DSResponse response, Object rawData,
			DSRequest request) {
		DataClass map = new DataClass(JSOHelper.createObject());
		JavaScriptObject[] objs = JSOHelper
				.toArray((JavaScriptObject) rawData);
		for (int i = 0; i < objs.length; i++) {
			DataClass row = new DataClass(objs[i]);
			map.setAttribute(row.getAttribute("riskTypeID"), row.getAttribute("riskTypeName"));
		}
		riskType.setAttribute("valueMap", map.getJsObj());
		risks.markForRedraw();
	}
});

Just two questions.

  1. I am new to Javascript, is what I have done above good?

  2. Is there a handler in the DataSource I can attach to to make this be executed on changes to the datasource?

Thanks.

So after looking through how smart clientparts work, I realise this would be to inherit a list grid and make a resultset for the valuemap. Then observe the resultset and on changes get a new valuemap.

I hope that is right. I’ll have a fiddle with some JSNI and see what I can get (I read somewhere ResultSet is the next big thing to be implemented in SmartGWT?)

I’ve started making a handler for the DataSource that triggers an event when data changes. Basically the same thing the ResultSets observe but for GWT. I’m just having some issues with the this.observe(this, “dataChange”, observer.“event firing method”) call. I haven’t had time to debug it, I hope the DataSource class has the observe method. I’ll post the interface, handler, event, addhandler method and some sample code when I get it working.