Hello,
How do I do grouping with a dropdown grid from a combobox?
Using 3.0 Smart GWT, and GWT 2.4.
I would like to have a combobox with a drop down grid and am trying to do some fun stuff with the grid. Like grouping my grid rows.
I am able to get a combobox with a dropdown grid with items. And think I should use the setPickListItems to change the properties to allow grouping.
I have grouping working in grid alone, but for some reason I can't get it to group when I have it in the drop down.
Here is what I have done.
Evan
private ComboBoxItem getCBSearchOn() {
cbSearchOn = new ComboBoxItem();
cbSearchOn.setDisplayField("enthead");
cbSearchOn.setSortField("enthead");
cbSearchOn.setValueField("enthead");
DataSource ds = DataSource.get("ravisearchon");
cbSearchOn.setOptionDataSource(ds);
// general settings
cbSearchOn.setHeight(28);
cbSearchOn.setWidth(450);
// comboBoxItemDiseases.setAnimationTime(3);
cbSearchOn.setCompleteOnTab(false);
// cbItem.setShowPickerIcon(true);
// TODO: tool tip on combo box does not format so well
cbSearchOn.setTooltip("<nobr>Start typing to reveal matches for your search.</nobr>");
// title to the left of combo box
cbSearchOn.setTitle("");
// TODO: consider using the following, and making the rankGrid be regularexpression matching to get things
// and then update the breadcrrumb to list everything matched...
// cbSearchOn.setAddUnknownValues(true);
setupPickListProperties();
cbSearchOn.setPickListProperties(pickListProperties);
cbSearchOn.setAnimatePickList(true);
// initialize and fetch when the UI loads up
cbSearchOn.setAutoFetchData(true);
cbSearchOn.setCanEdit(true);
cbSearchOn.setCanFocus(true);
cbSearchOn.setType("comboBox");
return cbSearchOn;
}
private void updateGroupFieldRank(ListGridField rviField) {
rviField.setType(ListGridFieldType.INTEGER);
rviField.setCellFormatter(new CellFormatter() {
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
if(value == null) return null;
try {
//NumberFormat nf = NumberFormat.getFormat("0,000");
//return nf.format(((Number) value).longValue());
NumberFormat nf = NumberFormat.getDecimalFormat();
return nf.format(((Number) value).longValue());
} catch (Exception e) {
return value.toString();
}
}
});
rviField.setGroupValueFunction(new GroupValueFunction() {
public Object getGroupValue(Object value, ListGridRecord record, ListGridField field, String fieldName, ListGrid grid) {
int type = (Integer) value;
return type;
}
});
rviField.setGroupTitleRenderer(new GroupTitleRenderer() {
public String getGroupTitle(Object groupValue, GroupNode groupNode, ListGridField field, String fieldName, ListGrid grid) {
final int groupType = (Integer) groupValue;
String baseTitle ="";
switch (groupType) {
case groupDiseases:
baseTitle = "Diseases";
break;
case groupDrugs:
baseTitle = "Drugs";
break;
}
baseTitle += " (" + groupNode.getGroupMembers().length + " members)";
return baseTitle;
}
});
}
private void setupPickListProperties() {
ListGridField typeField = new ListGridField("entfieldskey", "Type");
typeField.setWidth("10%");
typeField.setPrompt("Type of item");
// Request for grouping by rank
updateGroupFieldRank(typeField);
pickListProperties.setGroupByField("entfieldskey");
pickListProperties.setGroupStartOpen(GroupStartOpen.ALL);
ListGridField synField = new ListGridField("entsyn");
ListGridField termField = new ListGridField("enthead");
cbSearchOn.setPickListWidth(450);
cbSearchOn.setPickListFields(synField, termField, typeField);
}
How do I do grouping with a dropdown grid from a combobox?
Using 3.0 Smart GWT, and GWT 2.4.
I would like to have a combobox with a drop down grid and am trying to do some fun stuff with the grid. Like grouping my grid rows.
I am able to get a combobox with a dropdown grid with items. And think I should use the setPickListItems to change the properties to allow grouping.
I have grouping working in grid alone, but for some reason I can't get it to group when I have it in the drop down.
Here is what I have done.
Evan
private ComboBoxItem getCBSearchOn() {
cbSearchOn = new ComboBoxItem();
cbSearchOn.setDisplayField("enthead");
cbSearchOn.setSortField("enthead");
cbSearchOn.setValueField("enthead");
DataSource ds = DataSource.get("ravisearchon");
cbSearchOn.setOptionDataSource(ds);
// general settings
cbSearchOn.setHeight(28);
cbSearchOn.setWidth(450);
// comboBoxItemDiseases.setAnimationTime(3);
cbSearchOn.setCompleteOnTab(false);
// cbItem.setShowPickerIcon(true);
// TODO: tool tip on combo box does not format so well
cbSearchOn.setTooltip("<nobr>Start typing to reveal matches for your search.</nobr>");
// title to the left of combo box
cbSearchOn.setTitle("");
// TODO: consider using the following, and making the rankGrid be regularexpression matching to get things
// and then update the breadcrrumb to list everything matched...
// cbSearchOn.setAddUnknownValues(true);
setupPickListProperties();
cbSearchOn.setPickListProperties(pickListProperties);
cbSearchOn.setAnimatePickList(true);
// initialize and fetch when the UI loads up
cbSearchOn.setAutoFetchData(true);
cbSearchOn.setCanEdit(true);
cbSearchOn.setCanFocus(true);
cbSearchOn.setType("comboBox");
return cbSearchOn;
}
private void updateGroupFieldRank(ListGridField rviField) {
rviField.setType(ListGridFieldType.INTEGER);
rviField.setCellFormatter(new CellFormatter() {
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
if(value == null) return null;
try {
//NumberFormat nf = NumberFormat.getFormat("0,000");
//return nf.format(((Number) value).longValue());
NumberFormat nf = NumberFormat.getDecimalFormat();
return nf.format(((Number) value).longValue());
} catch (Exception e) {
return value.toString();
}
}
});
rviField.setGroupValueFunction(new GroupValueFunction() {
public Object getGroupValue(Object value, ListGridRecord record, ListGridField field, String fieldName, ListGrid grid) {
int type = (Integer) value;
return type;
}
});
rviField.setGroupTitleRenderer(new GroupTitleRenderer() {
public String getGroupTitle(Object groupValue, GroupNode groupNode, ListGridField field, String fieldName, ListGrid grid) {
final int groupType = (Integer) groupValue;
String baseTitle ="";
switch (groupType) {
case groupDiseases:
baseTitle = "Diseases";
break;
case groupDrugs:
baseTitle = "Drugs";
break;
}
baseTitle += " (" + groupNode.getGroupMembers().length + " members)";
return baseTitle;
}
});
}
private void setupPickListProperties() {
ListGridField typeField = new ListGridField("entfieldskey", "Type");
typeField.setWidth("10%");
typeField.setPrompt("Type of item");
// Request for grouping by rank
updateGroupFieldRank(typeField);
pickListProperties.setGroupByField("entfieldskey");
pickListProperties.setGroupStartOpen(GroupStartOpen.ALL);
ListGridField synField = new ListGridField("entsyn");
ListGridField termField = new ListGridField("enthead");
cbSearchOn.setPickListWidth(450);
cbSearchOn.setPickListFields(synField, termField, typeField);
}
Comment