PDA

View Full Version : Select Item From Grid



Adam_Germany
29 Apr 2010, 4:30 AM
I have a Problem with Selecting an Item from the Grid (GXT), because some Items are without (IDs).

------------------
id | name |
----------------- |
x | name1 | // CAN NOT BE SELECTED
x | name2 | // CAN NOT BE SELECTED
132 | name 3 | // can be selected
102 | name 4 | // can be selected
------------------

how can I select an object from the Grid, according the name and not the Id.

thx.

sven
29 Apr 2010, 4:34 AM
Can you please post some testcase for this that implements EntryPoint? Also you should post this in the correct forum, im oved it for now

Adam_Germany
29 Apr 2010, 4:53 AM
I fill the storeGrid with some Data , the Data are displayed on the Grid but some of them are not selectable.
.....
data.setId(null);// on the Grid not selectable
data.setName("Test1");
store.add(data);

data.setId(10120); // on the Grid is selectable
data.setName("Test2");
store.add(data);
......

grid = new Grid(store,cm);
....

sven
29 Apr 2010, 4:56 AM
That is not a testcase. It can be everything, so please post a fully wokring testcase that implements EntryPoint

Also make sure you implemented equals correctly, so it can handle ids set to null.

Adam_Germany
29 Apr 2010, 5:08 AM
@Override
public void onModuleLoad() {

....

ColumnModel cm = buildColumnModel();

labelGroupStore = buildModelStore();

// load after widget is rendered
addWidgetListener(new WidgetListener(){
@Override
public void widgetAttached(ComponentEvent ce) {
super.widgetAttached(ce);
labelGroupStore.getLoader().load();
}

});

// build Label Grid
labelsGrid = new Grid<BeanModel>(labelGroupStore, cm);

.....

}



private GroupingStore<BeanModel> buildModelStore() {

// Initialize the Store (read all available Models)
DataProxy<Model[]> modelProxy = new RpcProxy<Model[]>() {

@Override
protected void load(Object loadConfig,
final AsyncCallback<Model[]> callback) {

labelService.listAllLabelGroups(new AsyncCallback<Model[]>() {
@Override
public void onSuccess(Model[] arg0) {
callback.onSuccess(arg0);
// Model has id , name and subject
// From Server some Id are "" or null

}

@Override
public void onFailure(Throwable arg0) {
callback.onFailure(arg0);
}
});
}
};

ListLoader<ListLoadResult<BeanModel>> modelLoader = new BaseListLoader<ListLoadResult<BeanModel>>( modelProxy, new AdvancedBeanModelReader());
GroupingStore<BeanModel> labelGroupStore = new GroupingStore<BeanModel>(modelLoader);
}
}

sven
29 Apr 2010, 5:12 AM
That is still not a testcase, a testcase is something other persons can just run without any further depencies and see the problem

Adam_Germany
29 Apr 2010, 5:15 AM
ok I will do it Sorry