When I setData with a ResultSet from a DataSource.fetchData call, subsequent scrolling on the ListGrid causes the fetch operations to ignore fetchOperation set on the ListGrid (see attached png for DeveloperConsole RPC tab). I have tested this with Firefox 3.6 and SC_SNAPSHOT-2011-06-13/PowerEdition in hosted mode.
Here is reproducing code example:
Here is the ds.xml:
The refresh call would normally be run on a scheduled Timer rather than via button. I'm not sure how I'm messing up the scrolling with my manual fetch and set?
Here is reproducing code example:
Code:
package com.smartgwt.sample.client; import com.smartgwt.client.data.DSCallback; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.ResultSet; import com.smartgwt.client.types.FetchMode; import com.smartgwt.client.types.TextMatchStyle; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.Label; 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.layout.VLayout; public class RefreshGridTest extends VLayout { private ListGrid grid; private static final int REFRESH_ROW_OFFSET = 15; private static String DATASOURCE = "PING"; private static String FETCH_OP = "isOne"; private Label label; public RefreshGridTest() { setMargin(10); setWidth(400); setHeight(500); setMembersMargin(5); grid = new ListGrid(); grid.setDataSource(DataSource.get(DATASOURCE)); grid.setFetchOperation(FETCH_OP); grid.setWidth100(); grid.setHeight100(); grid.setShowFilterEditor(true); grid.setFetchDelay(1000); grid.setFilterOnKeypress(true); grid.setAutoFetchData(true); addMember(grid); label = new Label(); label.setHeight(16); label.setWidth(400); addMember(label); updateLabel(); final IButton button = new IButton("refresh"); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { refresh(); updateLabel(); } }); addMember(button); } private void updateLabel() { label.setContents(grid.getFetchOperation()); } private void refresh() { final Integer row[] = grid.getVisibleRows(); final DSRequest request = new DSRequest(); request.setStartRow(Math.max(0, row[0] - REFRESH_ROW_OFFSET)); request.setEndRow(row[1] + REFRESH_ROW_OFFSET); request.setSortBy(grid.getSort()); request.setOperationId(FETCH_OP); request.setTextMatchStyle(TextMatchStyle.SUBSTRING); final DataSource ds = grid.getDataSource(); ds.setShowPrompt(false); ds.fetchData(grid.getCriteria(), new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { final ResultSet resultset = new ResultSet(); resultset.setDataSource(ds); resultset.setCriteria(grid.getCriteria()); resultset.setFetchMode(FetchMode.PAGED); resultset.setInitialLength(response.getTotalRows()); resultset.setInitialData(response.getData()); resultset.setInitialSort(request.getSortBy()); grid.setData(resultset); } }, request); } }
Code:
<DataSource schema="PING" dbName="Oracle" tableName="PING" ID="PING" serverType="sql" > <fields> <field name="id" sequenceName="PING_SEQ" primaryKey="true" type="sequence" hidden="true"></field> <field name="name" length="51" type="text"> <validators> <validator type="isUnique" requiresServer="true" /> </validators> </field> <field name="other" length="21" type="text"></field> <field name="type" type="number"></field> </fields> <operationBindings> <operationBinding operationType="fetch" operationId="isOne"> <whereClause>$defaultWhereClause and type = 1</whereClause> </operationBinding> <operationBinding operationType="fetch" operationId="notOne"> <whereClause>$defaultWhereClause and type != 1</whereClause> </operationBinding> </operationBindings> </DataSource>
Comment