Hi Isomorphic,
please see this screenshot and the BuiltInDS-based testcase (v10.1p_2017-08-22).
I get that the framework can't select "Charles Madigan" in the case on the right, because he is not in the first 75 records. Also it is hard to get the position where in the list he will be, so the system can't easily issue a 2nd fetch for "Charles Madigan"+75 records and jump there, like it does in the case on the left. So it stays at the 1st record.
But it is not always this way. Sometimes the 2nd Picklist is just scrolled "somewhere" (or, more specific: The position where the other PickList (where Charles Madigan was selected) was scrolled). See the 2nd screenshot below.
![Click image for larger version Name: PicklistOnOpen.png Views: 1 Size: 40.8 KB ID: 248746](filedata/fetch?id=248746&d=1503685978)
See the scrollbar position:
![Click image for larger version Name: Scrollbar position.png Views: 1 Size: 24.7 KB ID: 248747](filedata/fetch?id=248747&d=1503686916)
To me it seems that after the PickList is closed not all properties are cleared. Perhaps you have a PickList pool where the instance is not "as new" for reuse in the 2nd ComboBoxItem?
BuiltInDS.java:
Best regards
Blama
please see this screenshot and the BuiltInDS-based testcase (v10.1p_2017-08-22).
I get that the framework can't select "Charles Madigan" in the case on the right, because he is not in the first 75 records. Also it is hard to get the position where in the list he will be, so the system can't easily issue a 2nd fetch for "Charles Madigan"+75 records and jump there, like it does in the case on the left. So it stays at the 1st record.
But it is not always this way. Sometimes the 2nd Picklist is just scrolled "somewhere" (or, more specific: The position where the other PickList (where Charles Madigan was selected) was scrolled). See the 2nd screenshot below.
See the scrollbar position:
To me it seems that after the PickList is closed not all properties are cleared. Perhaps you have a PickList pool where the instance is not "as new" for reuse in the 2nd ComboBoxItem?
BuiltInDS.java:
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.Criteria; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.SortSpecifier; import com.smartgwt.client.types.SortDirection; import com.smartgwt.client.types.TextMatchStyle; 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.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.ComboBoxItem; import com.smartgwt.client.widgets.form.fields.FormItem; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.layout.VLayout; public class BuiltInDS implements EntryPoint { private VLayout mainLayout; private IButton recreateBtn; 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(); } }); mainLayout = new VLayout(20); mainLayout.setWidth100(); mainLayout.setHeight100(); recreateBtn = new IButton("Recreate"); recreateBtn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { recreate(); } }); mainLayout.addMember(recreateBtn); recreate(); mainLayout.draw(); } private void recreate() { Window w = new Window(); w.setWidth("95%"); w.setHeight("95%"); w.setMembersMargin(0); w.setModalMaskOpacity(70); w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")"); w.setTitle("PickList does not always select current entry when opened." + w.getTitle()); w.setShowMinimizeButton(false); w.setIsModal(true); w.setShowModalMask(true); w.centerInPage(); { final DynamicForm employeesDF = new DynamicForm(); employeesDF.setIsGroup(true); employeesDF.setGroupTitle("ComboBoxItem ascending"); employeesDF.setDataSource(DataSource.get("employees")); FormItem employeeIdLGF = new FormItem("EmployeeId"); FormItem nameLGF = new FormItem("Name"); FormItem genderLGF = new FormItem("Gender"); MyComboBoxItem mcbi = new MyComboBoxItem("ReportsTo", SortDirection.ASCENDING); employeesDF.setFields(employeeIdLGF, nameLGF, genderLGF, mcbi); employeesDF.fetchData(new Criteria(employeeIdLGF.getName(), "182")); w.addItem(employeesDF); } { final DynamicForm employeesDF = new DynamicForm(); employeesDF.setIsGroup(true); employeesDF.setGroupTitle("ComboBoxItem descending"); employeesDF.setDataSource(DataSource.get("employees")); FormItem employeeIdLGF = new FormItem("EmployeeId"); FormItem nameLGF = new FormItem("Name"); FormItem genderLGF = new FormItem("Gender"); MyComboBoxItem mcbi = new MyComboBoxItem("ReportsTo", SortDirection.DESCENDING); employeesDF.setFields(employeeIdLGF, nameLGF, genderLGF, mcbi); employeesDF.fetchData(new Criteria(employeeIdLGF.getName(), "182")); w.addItem(employeesDF); } w.show(); } private class MyComboBoxItem extends ComboBoxItem { public MyComboBoxItem(String name, SortDirection sortDirection) { super(name); setOptionDataSource(DataSource.get("employees")); setValueField(DataSource.get("employees").getPrimaryKeyFieldName()); setDisplayField("Name"); setPickListProperties(new ListGrid() { { setDrawAllMaxCells(75); // Disable automatic 2nd fetch because of <= 125 employees / 250 cells. } }); setPickListSort(new SortSpecifier[] { new SortSpecifier("Name", sortDirection) }); ListGridField nameLGF = new ListGridField("Name"); ListGridField genderLGF = new ListGridField("Gender"); setPickListFields(nameLGF, genderLGF); setPickListWidth(350); setTextMatchStyle(TextMatchStyle.SUBSTRING); setBrowserSpellCheck(false); setAddUnknownValues(false); } } }
Blama
Comment