Hi Isomorphic,
using latest 5.1p (v10.1p_2017-04-04) I noticed that setPickListSort() called before creation of the ComboBoxItem does not sort the contents, only setInitialSort() does.
I'm pretty sure this worked before. I do not know when this behavior changed.
Please see this testcase:
BuiltInDS.java:
This is an important one for me.
Best regards
Blama
using latest 5.1p (v10.1p_2017-04-04) I noticed that setPickListSort() called before creation of the ComboBoxItem does not sort the contents, only setInitialSort() does.
I'm pretty sure this worked before. I do not know when this behavior changed.
Please see this testcase:
BuiltInDS.java:
Code:
package com.smartgwt.sample.client;
import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.core.KeyIdentifier;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.SortSpecifier;
import com.smartgwt.client.types.FetchMode;
import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.types.TextMatchStyle;
import com.smartgwt.client.types.VerticalAlignment;
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.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.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;
public class BuiltInDS implements EntryPoint {
private VLayout mainLayout;
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();
HLayout buttonsLayout = new HLayout();
buttonsLayout.setHeight(30);
IButton recreateBtn = new IButton("Recreate");
recreateBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
recreate();
}
});
buttonsLayout.addMember(recreateBtn);
mainLayout.addMember(buttonsLayout);
mainLayout.setAlign(VerticalAlignment.TOP);
recreate();
mainLayout.draw();
}
private void recreate() {
if (mainLayout.getMembersLength() > 1) {
mainLayout.removeMember(mainLayout.getMember(1));
}
mainLayout.addMember(getComponent(), 1);
}
private DynamicForm getComponent() {
DynamicForm df = new DynamicForm();
MyComboBoxItem mcbi1 = new MyComboBoxItem(false);
mcbi1.setTitle("Unsorted (wrong)");
MyComboBoxItem mcbi2 = new MyComboBoxItem(true);
mcbi2.setTitle("Sorted (correct)");
df.setFields(mcbi1, mcbi2);
return df;
}
private class MyComboBoxItem extends ComboBoxItem {
public MyComboBoxItem(boolean useInitial) {
setOptionDataSource(DataSource.get("employees"));
setValueField(DataSource.get("employees").getPrimaryKeyFieldName());
setAllowEmptyValue(true);
ListGridField employeeId = new ListGridField("EmployeeId");
employeeId.setHidden(true);
ListGridField name = new ListGridField("Name");
ListGridField gender = new ListGridField("Gender");
ListGridField job = new ListGridField("Job");
setPickListFields(employeeId, name, gender, job);
// See here
if (useInitial)
setInitialSort(new SortSpecifier[] { new SortSpecifier(gender.getName(), SortDirection.ASCENDING),
new SortSpecifier(name.getName(), SortDirection.ASCENDING) });
else
setPickListSort(new SortSpecifier[] { new SortSpecifier(gender.getName(), SortDirection.ASCENDING),
new SortSpecifier(name.getName(), SortDirection.ASCENDING) });
setPickListHeaderHeight(0);
setPickListWidth(350);
setTextMatchStyle(TextMatchStyle.SUBSTRING);
setBrowserSpellCheck(false);
setAddUnknownValues(false);
setPickListProperties(new ListGrid() {
{
setDataFetchMode(FetchMode.BASIC);
}
});
}
}
}
Best regards
Blama
Comment