gxt中的组合框选择问题
我使用 GXT-2.1.1 开发该项目。我想在网格中显示选中(复选框)的选定车辆组的车辆详细信息。我有车辆组组合框,它显示组名。如何显示所选组名的车辆。我使用两个商店 1.storeVehicleFrom 包含所有车辆详细信息,2.storeTempVehicleFrom 仅包含下组车辆。下面是我的源代码。它将显示错误 msg classcastException。如何解决此问题。
ComboBox<VehicleGroupModel> comboGroup = new ComboBox<VehicleGroupModel>();
ListStore<VehicleGroupModel> storeGroup = new ListStore<VehicleGroupModel>();
ListStore<VehicleGroupModel> storeVehicleFrom =new ListStore<VehicleGroupModel> ();
ListStore<VehicleGroupModel> storeTempVehicleFrom = new ListStore<VehicleGroupModel>();// Temp. store
// combolistener
SelectionChangedListener<VehicleGroupModel> comboListener =new SelectionChangedListener<VehicleGroupModel>(){
@Override
public void selectionChanged(SelectionChangedEvent<VehicleGroupModel> se) {
VehicleGroupModel vg = se.getSelectedItem();
Record record = storeGroup.getRecord(vg);
ProcessGroupSelection(record);
}
};
private void ProcessGroupSelection(Record record){
try{
int groupId = record.getModel().get("groupId");
disableFlag = false;
//if(groupDetailList == null || groupDetailList.size() <= 0) return;commented by meena
for(int i = 0; i < groupDetailList.size(); i++){ // all the vehicles are unchecked first
VehicleGroupDetails groupDetail = (VehicleGroupDetails)groupDetailList.get(i);
Integer vehicleId = new Integer(groupDetail.getVehicleId());
Record vehicleRecord = storeVehicleFrom.getRecord(storeVehicleFrom.getAt(0));//getAt(0).get("vehicleId");
vehicleRecord.set("vehicleId", vehicleId.toString());
vehicleRecord.set("Add", false);
}
storeTempVehicleFrom.removeAll(); // store the checkbox checked for the selected group
for(int i = 0; i < groupDetailList.size(); i++){
VehicleGroupDetails groupDetail = (VehicleGroupDetails)groupDetailList.get(i);
if(groupId == groupDetail.getGroupId()){
Integer vehicleId = new Integer(groupDetail.getVehicleId());
Record vehicleRecord = storeVehicleFrom.getRecord(storeVehicleFrom.getAt(0));
vehicleRecord.set("vehicleId", vehicleId.toString());
vehicleRecord.set("Add", true);
storeTempVehicleFrom.add(vehicleRecord);
}
disableFlag = true;
}
int[] existsInGroup = new int[storeGroup.getCount()] ;//All the below is for getting the ungrouped vehicles by
//storing the vehicle ids present in vehicle Group into array and then comparing with vehicle list and get the remaining ungrouped vehicles.
if (storeTempVehicleFrom.getCount() == 0)
{
disableFlag = false;
for(int i = 0; i < groupDetailList.size(); i++){
VehicleGroupDetails groupDetail = (VehicleGroupDetails)groupDetailList.get(i);
for(int j=0;j< AppContext.companyVehicles.length;j++)
{
Vehicle vehicle =AppContext.companyVehicles[j];
//System.out.println("vehicle id in List "+vehicle.getId().getVehicleId()+"total Group id "+groupDetail.getVehicleId());
if(vehicle.getId().getVehicleId() == groupDetail.getVehicleId())
{
existsInGroup[i] = vehicle.getId().getVehicleId() ;
continue;
}
}
}
int flag =0;
Integer vehicleId = null ;
for(int i = 0; i < AppContext.companyVehicles.length; i++){
//System.out.println("Exists in Group "+existsInGroup.length);
for(int k=0;k<existsInGroup.length;k++)
{
//System.out.println(" "+existsInGroup[k]+" "+AppContext.companyVehicles[i].getId().getVehicleId());
vehicleId = new Integer(AppContext.companyVehicles[i].getId().getVehicleId());
if (vehicleId == existsInGroup[k])
{
flag =1;
break;
}
}
//System.out.println("Flag :"+flag);
if(flag !=1){
Record vehicleRecord = storeVehicleFrom.getRecord(storeVehicleFrom.getAt(0));
vehicleRecord.set("Add", true);
storeTempVehicleFrom.add(vehicleRecord);
}
flag =0;
}
}
storeVehicleFrom.commitChanges();
storeTempVehicleFrom.commitChanges();
}
catch(Exception e){
ExceptionHandler.performDefaultErrorHandling(e);
}
}
Im developing the project by using GXT-2.1.1. I want to display vehicle details for selected vehicleGroup in the grid with checked(checkbox). Im having vehicleGroup combobox it is displaying groupname. How to display the vehicles for selected groupname. Im using two store 1.storeVehicleFrom having all vehicle details and 2.storeTempVehicleFrom having only the under group vehicles. Here under i my sorce code. It will display error msg classcastException.How to solve this issue.
ComboBox<VehicleGroupModel> comboGroup = new ComboBox<VehicleGroupModel>();
ListStore<VehicleGroupModel> storeGroup = new ListStore<VehicleGroupModel>();
ListStore<VehicleGroupModel> storeVehicleFrom =new ListStore<VehicleGroupModel> ();
ListStore<VehicleGroupModel> storeTempVehicleFrom = new ListStore<VehicleGroupModel>();// Temp. store
// combolistener
SelectionChangedListener<VehicleGroupModel> comboListener =new SelectionChangedListener<VehicleGroupModel>(){
@Override
public void selectionChanged(SelectionChangedEvent<VehicleGroupModel> se) {
VehicleGroupModel vg = se.getSelectedItem();
Record record = storeGroup.getRecord(vg);
ProcessGroupSelection(record);
}
};
private void ProcessGroupSelection(Record record){
try{
int groupId = record.getModel().get("groupId");
disableFlag = false;
//if(groupDetailList == null || groupDetailList.size() <= 0) return;commented by meena
for(int i = 0; i < groupDetailList.size(); i++){ // all the vehicles are unchecked first
VehicleGroupDetails groupDetail = (VehicleGroupDetails)groupDetailList.get(i);
Integer vehicleId = new Integer(groupDetail.getVehicleId());
Record vehicleRecord = storeVehicleFrom.getRecord(storeVehicleFrom.getAt(0));//getAt(0).get("vehicleId");
vehicleRecord.set("vehicleId", vehicleId.toString());
vehicleRecord.set("Add", false);
}
storeTempVehicleFrom.removeAll(); // store the checkbox checked for the selected group
for(int i = 0; i < groupDetailList.size(); i++){
VehicleGroupDetails groupDetail = (VehicleGroupDetails)groupDetailList.get(i);
if(groupId == groupDetail.getGroupId()){
Integer vehicleId = new Integer(groupDetail.getVehicleId());
Record vehicleRecord = storeVehicleFrom.getRecord(storeVehicleFrom.getAt(0));
vehicleRecord.set("vehicleId", vehicleId.toString());
vehicleRecord.set("Add", true);
storeTempVehicleFrom.add(vehicleRecord);
}
disableFlag = true;
}
int[] existsInGroup = new int[storeGroup.getCount()] ;//All the below is for getting the ungrouped vehicles by
//storing the vehicle ids present in vehicle Group into array and then comparing with vehicle list and get the remaining ungrouped vehicles.
if (storeTempVehicleFrom.getCount() == 0)
{
disableFlag = false;
for(int i = 0; i < groupDetailList.size(); i++){
VehicleGroupDetails groupDetail = (VehicleGroupDetails)groupDetailList.get(i);
for(int j=0;j< AppContext.companyVehicles.length;j++)
{
Vehicle vehicle =AppContext.companyVehicles[j];
//System.out.println("vehicle id in List "+vehicle.getId().getVehicleId()+"total Group id "+groupDetail.getVehicleId());
if(vehicle.getId().getVehicleId() == groupDetail.getVehicleId())
{
existsInGroup[i] = vehicle.getId().getVehicleId() ;
continue;
}
}
}
int flag =0;
Integer vehicleId = null ;
for(int i = 0; i < AppContext.companyVehicles.length; i++){
//System.out.println("Exists in Group "+existsInGroup.length);
for(int k=0;k<existsInGroup.length;k++)
{
//System.out.println(" "+existsInGroup[k]+" "+AppContext.companyVehicles[i].getId().getVehicleId());
vehicleId = new Integer(AppContext.companyVehicles[i].getId().getVehicleId());
if (vehicleId == existsInGroup[k])
{
flag =1;
break;
}
}
//System.out.println("Flag :"+flag);
if(flag !=1){
Record vehicleRecord = storeVehicleFrom.getRecord(storeVehicleFrom.getAt(0));
vehicleRecord.set("Add", true);
storeTempVehicleFrom.add(vehicleRecord);
}
flag =0;
}
}
storeVehicleFrom.commitChanges();
storeTempVehicleFrom.commitChanges();
}
catch(Exception e){
ExceptionHandler.performDefaultErrorHandling(e);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论