Hi folks, I have a below a simple scenario:
1. I have a grid populated with data 2. I select any 1 row from grid - data with a specific "Object Id" [internal id] 3. I press a refresh button from a paginationToolbar 4. data are refreshed 5. no row from grid is being selected. Question 1: How can I change a step 5, so after refresh a row with specific Object Id (from step 2) would be automaticaly selected? I tried to implement a LoadListener to loader, but it seems like I'm incorrectly selecting a row from my grid. Here is a bit of my code: 1. A global variable of type "Zakazka" to store a Zakazka before refresh occures (the one which should be selected after refresh): Code: private Zakazka selectedZakazka; 2. Here is my grid definition with loader's load listener Code: RpcProxy<PagingLoadResult<Zakazka>> proxy = new RpcProxy<PagingLoadResult<Zakazka>>() { @Override public void load(Object loadConfig, AsyncCallback<PagingLoadResult<Zakazka>> callback) { Tracing.Log("ZakazkyAktivne.RpcProxy.load.before"); service.getZakazky((PagingLoadConfig) loadConfig, callback); Tracing.Log("ZakazkyAktivne.RpcProxy.load.after"); } }; // loader final PagingLoader<PagingLoadResult<ModelData>> loader = new BasePagingLoader<PagingLoadResult<ModelData>>(proxy); loader.setRemoteSort(true); ListStore<Zakazka> store = new ListStore<Zakazka>(loader); pagingToolBar = new PagingToolBar(50); pagingToolBar.bind(loader); List<ColumnConfig> columns = new ArrayList<ColumnConfig>(); columns.add(new ColumnConfig("object_id", "Object Id", 80)); columns.add(new ColumnConfig("cislo_dokladu", "Číslo dokladu", 100)); ColumnConfig created = new ColumnConfig("created", "Dátum vytvorenia", 105); created.setDateTimeFormat(DateTimeFormat.getFormat("dd.MM.yyyy HH:mm:ss")); columns.add(created); columns.add(new ColumnConfig("objednavatel", "Objednavatel", 120)); columns.add(new ColumnConfig("stredisko", "Stredisko", 150)); columns.add(new ColumnConfig("stav_zakazky_id", "Id stavu zakazky", 60)); columns.add(new ColumnConfig("stav_zakazky_kod", "Kód stavu zakazky", 100)); columns.add(new ColumnConfig("stav_zakazky", "Stav zakazky", 100)); columns.add(new ColumnConfig("stav_zakazky_zmenil_uziv_meno", "Zakazku změnil", 100)); ColumnConfig updated = new ColumnConfig("stav_zakazky_zmena", "Dátum změny", 105); updated.setDateTimeFormat(DateTimeFormat.getFormat("dd.MM.yyyy HH:mm:ss")); columns.add(updated); ColumnModel cm = new ColumnModel(columns); gridZakazka = new Grid<Zakazka>(store, cm); gridZakazka.setStateId("pagingGridExample"); gridZakazka.setStateful(true); gridZakazka.addListener(Events.Attach, new Listener<GridEvent<Zakazka>>() { public void handleEvent(GridEvent<Zakazka> be) { PagingLoadConfig config = new BasePagingLoadConfig(); config.setOffset(0); config.setLimit(50); Map<String, Object> state = gridZakazka.getState(); if (state.containsKey("offset")) { int offset = (Integer)state.get("offset"); int limit = (Integer)state.get("limit"); config.setOffset(offset); config.setLimit(limit); } if (state.containsKey("sortField")) { config.setSortField((String)state.get("sortField")); config.setSortDir(SortDir.valueOf((String)state.get("sortDir"))); } loader.load(config); } }); gridZakazka.getSelectionModel().addListener(Events.SelectionChange, new Listener<SelectionChangedEvent<Zakazka>>() { public void handleEvent(SelectionChangedEvent<Zakazka> be) { if (be.getSelection().size() > 0) { Tracing.Log("Grid selection changed"); formBindings.bind((ModelData) be.getSelection().get(0)); setZakazkaDetailToolBar(be.getSelectedItem().getZakazkaObjectId(), be.getSelectedItem().getZakazkaStavZakazkyId()); // getLogZakazkaGrid(be.getSelectedItem().getZakazkaObjectId()); //pagingToolBarLog.refresh(); } else { Tracing.Log("Nothing selected"); formBindings.unbind(); zakazkaDetailToolBar.removeAll(); } } }); loader.addLoadListener(new LoadListener() { @Override public void loaderLoad(LoadEvent le) { // Run your selection logic here Tracing.Log("loaderLoad invoked!"); gridZakazka.getSelectionModel().select(selectedZakazka, false); Tracing.Log("selectedZakazka selected"); } }); gridZakazka.setLoadMask(true); gridZakazka.setBorders(true); 3. Selected zakazka is remembered before refresh using a below code: Code: public void changeZakazkaStatus(Integer zakazkaId, Integer novyStatusId) { final DatabaseServiceAsync service = (DatabaseServiceAsync) Registry.get(Agdoprava.SERVICE); AsyncCallback<Boolean> callback = new AsyncCallback<Boolean>() { public void onFailure(Throwable caught) { System.out.println(caught.getMessage()); } public void onSuccess(Boolean result) { if (result) { Tracing.Log("Zakazka STATUS updated successfully!"); selectedZakazka = gridZakazka.getSelectionModel().getSelectedItem(); Tracing.Log("Selected zakazka Object ID:" + selectedZakazka.getZakazkaObjectId()); // refresh main grid pagingToolBar.refresh(); Tracing.Log("Refresh OK"); } else { Tracing.Log("Zakazka STATUS update failed!"); } } }; // execute RPC service.updateZakazkaStatus(zakazkaId, novyStatusId, StaticDataController.LoggedUzivatelId, callback); } 4. Tracing log Code: 2010-11-19 09:06:13.739| Zakazka STATUS updated successfully! 2010-11-19 09:06:13.739| Selected zakazka Object ID:123 2010-11-19 09:06:14.066| ZakazkyAktivne.RpcProxy.load.before 2010-11-19 09:06:14.082| ZakazkyAktivne.RpcProxy.load.after 2010-11-19 09:06:14.082| Refresh OK ZakazkaManager.getZakazky() 2010-11-19 09:06:14.436| Nothing selected 2010-11-19 09:06:14.877| loaderLoad invoked! 2010-11-19 09:06:14.877| selectedZakazka selected >From my tracing log I can see, that selectedZakazka is set correctly and prior refresh and also that loader.LoadListener is invoked after refresh. Just a row in grid stays unselected. So, I assume a piece of code in loader's LoadListener [in step 2 above] is incorrect, or uncomplete. Could you please suggest how to correct it, so selectedZakazka will be also selected after refresh? Many thanks, Tomas -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.