Rpc-Combo Box loading problem.

52 views
Skip to first unread message

Thiru

unread,
Jan 7, 2008, 5:42:45 PM1/7/08
to GWT-Ext Developer Forum
Hi,

I am trying to populate the combo box using the rpc call, but could'nt
get through.

Here is what i am doing..

ComboBox companySelection = new ComboBox(new ComboBoxConfig()
{
{
setMinChars(1);
setFieldLabel("Code");
setEmptyText("N/A");
setTypeAhead(true);
setSelectOnFocus(true);
setWidth(235);
setName("companyName");
setHiddenName("key");
setStore(getCompany());
setDisplayField("value");
setValueField("key");
setTriggerAction(ComboBox.ALL);
setResizable(true);
}
});

private Store getCompany()
{
final RecordDef recordDef = new RecordDef(
new FieldDef[] {
new StringFieldDef("key"),
new StringFieldDef("value")
}
);
final Store companyStore = new Store(recordDef);
asyncCall.getCompanyCode(new AsyncCallback()
{
public void onSuccess(Object result)
{
MemoryProxy memoryProxy = new MemoryProxy((String[][]) result);
companyStore.setProxy(memoryProxy);
companyStore.reload();
companyStore.commitChanges();
}
public void onFailure(Throwable caught)
{
Window.alert("Error: " + caught.getMessage());
}
});

return companyStore;
}

i tried companyStore.load(). Also i tried with simplestore.. I am i
doing something wrong??

it didnt showed me any exception, it retrieved the data from the
server, but it didnt populated it.
it always shows the loading gif when i click the combobox.

Regards,
Thiru.

Sanjiv Jivan

unread,
Jan 8, 2008, 10:13:56 PM1/8/08
to gwt...@googlegroups.com
Since you're manually getting data to add to the Store, you should setMode(ComboBox.LOCAL) in your ComboBoxConfig.


In your callback, try adding data to the Store as follows :

       String[][] results = ...
        for (int i = 0; i < results.length; i++) {
            String[] rowData = data[i];
            Record record = recordDef.createRecord(rowData);
            companyStore.add(record);
        }

        companyStore.commitChanges();

I'll look into why your code that uses MemoryProxy doesn't appear to be loading the Store.

Sanjiv
Reply all
Reply to author
Forward
0 new messages