Hi Isomorphic,
my main layout is a SectionStack filled with grouped ListGrid in it's sections. I create the ListGrids and load data lazy on SectionStackSection-open.
Now the users are asking for a total row count in each ListGrid, which I'd like to display in the SectionStackSection-title after the ListGrid loads.
This works fine with a DataArrivedHandler in the ListGrid after DB-fetches and after filtering (local as well as for a DB-fetch with criteria).
It does not work for updates (change the lifeSpan in the ListGrid in the attached sample). The DataArrivedHandler is hit, but ListGrid.getResultSet().getLength() does return the same value as before.
Like for local filtering, I'd expect the value to be correct (so +1, if the ResultSet got bigger or -1 if the update removed the row from the ResultSet.
Also, for a remove (delete a record via the delete button at the end of the row the attached sample), DataArrivedHandler is not hit.
Can you tell me if one or both of these behaviors are bugs, and if not, how to best solve this usecase?
BuiltInDS.java (v10.1p_2017-10-05):
Thank you & Best regards
Blama
my main layout is a SectionStack filled with grouped ListGrid in it's sections. I create the ListGrids and load data lazy on SectionStackSection-open.
Now the users are asking for a total row count in each ListGrid, which I'd like to display in the SectionStackSection-title after the ListGrid loads.
This works fine with a DataArrivedHandler in the ListGrid after DB-fetches and after filtering (local as well as for a DB-fetch with criteria).
It does not work for updates (change the lifeSpan in the ListGrid in the attached sample). The DataArrivedHandler is hit, but ListGrid.getResultSet().getLength() does return the same value as before.
Like for local filtering, I'd expect the value to be correct (so +1, if the ResultSet got bigger or -1 if the update removed the row from the ResultSet.
Also, for a remove (delete a record via the delete button at the end of the row the attached sample), DataArrivedHandler is not hit.
Can you tell me if one or both of these behaviors are bugs, and if not, how to best solve this usecase?
BuiltInDS.java (v10.1p_2017-10-05):
Code:
package com.smartgwt.sample.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.Version; import com.smartgwt.client.core.KeyIdentifier; import com.smartgwt.client.data.AdvancedCriteria; import com.smartgwt.client.data.Criterion; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.types.OperatorId; import com.smartgwt.client.util.Page; import com.smartgwt.client.util.PageKeyHandler; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.events.DataArrivedEvent; import com.smartgwt.client.widgets.grid.events.DataArrivedHandler; import com.smartgwt.client.widgets.layout.VLayout; public class BuiltInDS extends VLayout implements EntryPoint { public void onModuleLoad() { KeyIdentifier debugKey = new KeyIdentifier(); debugKey.setCtrlKey(true); debugKey.setKeyName("D"); Page.registerKey(debugKey, new PageKeyHandler() { public void execute(String keyName) { SC.showConsole(); } }); setWidth100(); setHeight100(); final IButton recreateBtn = new IButton("Recreate"); recreateBtn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { new MyWindow().show(); } }); addMember(recreateBtn); new MyWindow().show(); draw(); } private class MyWindow extends Window { public MyWindow() { setBackgroundColor("#F5F5F5"); setBodyColor("#F5F5F5"); setCanFocus(true); setWidth(800); setHeight(1000); setMembersMargin(0); setModalMaskOpacity(70); setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")"); setTitle("ListGrid DataArrivedHandler / ResultSet size/totalRows issue after delete/update" + getTitle()); setShowMinimizeButton(false); setIsModal(true); setShowModalMask(true); centerInPage(); ListGrid animalsLG1 = new AnimalsLG("animalsLG1"); ListGrid animalsLG2 = new AnimalsLG("animalsLG2"); VLayout messagesVLayout = new VLayout(10); messagesVLayout.setWidth100(); messagesVLayout.addMembers(animalsLG1, animalsLG2); addItem(messagesVLayout); animalsLG1.fetchData(new AdvancedCriteria(new Criterion("lifeSpan", OperatorId.LESS_OR_EQUAL, 20))); animalsLG2.fetchData(new AdvancedCriteria(new Criterion("lifeSpan", OperatorId.GREATER_THAN, 20))); } } private class AnimalsLG extends ListGrid { public AnimalsLG(final String lgName) { super(DataSource.get("animals")); setCanEdit(true); setCanRemoveRecords(true); setAutoFetchData(false); setAllowFilterExpressions(true); setShowFilterEditor(true); setWidth100(); ListGridField commonNameLGF = new ListGridField("commonName"); commonNameLGF.setCanFilter(false); ListGridField scientificNameLGF = new ListGridField("scientificName"); scientificNameLGF.setCanFilter(false); ListGridField lifeSpanLGF = new ListGridField("lifeSpan"); ListGridField statusLGF = new ListGridField("status"); statusLGF.setCanFilter(false); ListGridField dietLGF = new ListGridField("diet"); dietLGF.setCanFilter(false); setFields(commonNameLGF, scientificNameLGF, lifeSpanLGF, statusLGF, dietLGF); setSortField("commonName"); addDataArrivedHandler(new DataArrivedHandler() { @Override public void onDataArrived(DataArrivedEvent event) { int i = AnimalsLG.this.getResultSet().getLength(); SC.logWarn(lgName + "-Result length: " + i); } }); } } }
Blama
Comment