Hi Isomorphic;
My SmartGWT version is: 'v11.0p_2017-02-11/PowerEdition Deployment (built 2017-02-11)'.
My application is using SmartGWT + Spring + Hibernate.
I am facing issue with multi select dropdown in the grid.
My grid is fetching data from a database view. (material_attr_v) , base table for view is material_attr.
Entity for view:
@Entity
@Table(name = "material_attr_v")
public class MaterialAttrViewEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "material_attr_id")
private Integer materialAttrId;
@Column(name = "PREP_CODE")
private String materialPrepDesc;
}
Entity for table:
@Entity
@Table(name = "material_attr")
public class MaterialAttr {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "material_attr_id")
@Access(AccessType.PROPERTY)
private int materialAttrId;
@OneToMany(mappedBy ="materialAttr" , fetch = FetchType.EAGER,cascade = CascadeType.ALL)
private List<MaterialPrep> materialPrep;
}
Code for Select Item editor in the grid:
protected static FormItem getEditorForAdditionalFields(ListGridEditorContext context,
ListGrid materialAttributeGrid2) {
SelectItem prepClassSelectItem= new SelectItem();
final DataSource codeDS = DataSource.get("Code");
prepClassSelectItem.setWidth(300);
ListGridField codeField = new ListGridField("code");
codeField.setWidth(100);
codeField.setTitle("Prep Class");
ListGridField codeDescField = new ListGridField("Description");
codeDescField.setTitle("Description");
codeDescField.setShowHover(true);
codeDescField.setWidth(200);
prepClassSelectItem.setDisplayField("code");
prepClassSelectItem.setValueField("codeId");
prepClassSelectItem.setPickListFields(codeField, codeDescField);
prepClassSelectItem.setOptionDataSource(codeDS);
Criteria criteria = new Criteria();
criteria.addCriteria("name", "attrUOM");
prepClassSelectItem.setOptionCriteria(criteria);
prepClassSelectItem.setMultiple(true);
return prepClassSelectItem;
}
MaterialAttrView.ds.xml:
<DataSource ID="MaterialAttrView"
schemaBean="com.assaabloy.pricebook.server.persistence.model.MaterialAttrViewEntity">
<field name="materialAttrId" hidden="true" primaryKey="true" />
<field name="materialPrepDesc" includeFrom="code.code" hidden="true"/>
<field name="materialPrepDesc" type="text" title="Material Prep" displayField="materialPrepDesc" width="150"/>
</DataSource>
Code.ds.xml:
<DataSource ID="Code" schemaBean="com.assaabloy.pricebook.server.persistence.model.Code" >
<field name="codeId" hidden="true" primaryKey="true" />
<field name="code" type="text" title="Code" width="150"/>
<field name="description" type="text" title="Code" width="150"/>
</DataSource>
Now I am facing below 2 issues with this select item:
1. It displays value field in place of display field while editing.
Once the value are saved into DB, it shows the display field correctly.
2. It don't show the selected items checked in drop down.
Please suggest.
My SmartGWT version is: 'v11.0p_2017-02-11/PowerEdition Deployment (built 2017-02-11)'.
My application is using SmartGWT + Spring + Hibernate.
I am facing issue with multi select dropdown in the grid.
My grid is fetching data from a database view. (material_attr_v) , base table for view is material_attr.
Entity for view:
@Entity
@Table(name = "material_attr_v")
public class MaterialAttrViewEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "material_attr_id")
private Integer materialAttrId;
@Column(name = "PREP_CODE")
private String materialPrepDesc;
}
Entity for table:
@Entity
@Table(name = "material_attr")
public class MaterialAttr {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "material_attr_id")
@Access(AccessType.PROPERTY)
private int materialAttrId;
@OneToMany(mappedBy ="materialAttr" , fetch = FetchType.EAGER,cascade = CascadeType.ALL)
private List<MaterialPrep> materialPrep;
}
Code for Select Item editor in the grid:
protected static FormItem getEditorForAdditionalFields(ListGridEditorContext context,
ListGrid materialAttributeGrid2) {
SelectItem prepClassSelectItem= new SelectItem();
final DataSource codeDS = DataSource.get("Code");
prepClassSelectItem.setWidth(300);
ListGridField codeField = new ListGridField("code");
codeField.setWidth(100);
codeField.setTitle("Prep Class");
ListGridField codeDescField = new ListGridField("Description");
codeDescField.setTitle("Description");
codeDescField.setShowHover(true);
codeDescField.setWidth(200);
prepClassSelectItem.setDisplayField("code");
prepClassSelectItem.setValueField("codeId");
prepClassSelectItem.setPickListFields(codeField, codeDescField);
prepClassSelectItem.setOptionDataSource(codeDS);
Criteria criteria = new Criteria();
criteria.addCriteria("name", "attrUOM");
prepClassSelectItem.setOptionCriteria(criteria);
prepClassSelectItem.setMultiple(true);
return prepClassSelectItem;
}
MaterialAttrView.ds.xml:
<DataSource ID="MaterialAttrView"
schemaBean="com.assaabloy.pricebook.server.persistence.model.MaterialAttrViewEntity">
<field name="materialAttrId" hidden="true" primaryKey="true" />
<field name="materialPrepDesc" includeFrom="code.code" hidden="true"/>
<field name="materialPrepDesc" type="text" title="Material Prep" displayField="materialPrepDesc" width="150"/>
</DataSource>
Code.ds.xml:
<DataSource ID="Code" schemaBean="com.assaabloy.pricebook.server.persistence.model.Code" >
<field name="codeId" hidden="true" primaryKey="true" />
<field name="code" type="text" title="Code" width="150"/>
<field name="description" type="text" title="Code" width="150"/>
</DataSource>
Now I am facing below 2 issues with this select item:
1. It displays value field in place of display field while editing.
Once the value are saved into DB, it shows the display field correctly.
2. It don't show the selected items checked in drop down.
Please suggest.
Comment