I have problem filtering the CB based on the selection of another CB. What am I doing wrong/missing.Please help. I have this first CB which gets the Bank names and this second CB which gets the bank branches based on the selection of the previous CB i.e. Bank. Now when the user selects the bank name I want to filter the second CB i.e. the bank branch to show only related branches of that bank.
I have this BankDS.ds.xml which is used by the first CB to fill the Bank CB and I have this second BankBranchDS.ds.xml(code shown below) which fills the Bank Branch CB.
I am using this version SmartClient Version: v8.3p_2014-04-23/PowerEdition Deployment (built 2014-04-23) and testing on Firefox browser version 23
This is my DSRequest output
{
dataSource:"BankBranchDS",
operationType:"fetch",
componentId:"isc_PickListMenu_10",
data:{
fieldName:"bankid",
operator:"equals",
value:1
},
startRow:0,
endRow:75,
textMatchStyle:"startsWith",
resultSet:[ResultSet ID:isc_ResultSet_11 (created by: isc_PickListMenu_10)],
callback:{
caller:[ResultSet ID:isc_ResultSet_11 (created by: isc_PickListMenu_10)],
methodName:"fetchRemoteDataReply"
},
willHandleError:true,
showPrompt:false,
prompt:"Finding Records that match your criteria...",
oldValues:{
fieldName:"bankid",
operator:"equals",
value:1
},
requestId:"BankBranchDS$62712",
internalClientContext:{
requestIndex:{
Class:"Number",
formatter:"toString",
localeStringFormatter:"toString",
localeProperties:Obj
}
},
fallbackToEval:false,
bypassCache:true
}
This is my Response output
[
{
data:[
{
bankid:1,
id:1,
perName:"",
bank:{
id:1,
createdBy:1,
created:null,
perName:"",
lastUpdated:null,
engName:"M Bank",
updatedBy:null
},
code:"11001"
},
{
bankid:1,
id:2,
perName:"",
bank:{
id:1,
createdBy:1,
created:null,
perName:"",
lastUpdated:null,
engName:"M Bank",
updatedBy:null
},
code:"2333"
},
{
bankid:1,
id:3,
perName:"",
bank:{
id:1,
createdBy:1,
created:null,
perName:"",
lastUpdated:null,
engName:"M Bank",
updatedBy:null
},
code:"47"
},
{
bankid:2,
id:4,
perName:"",
bank:{
id:2,
createdBy:1,
created:new Date(1405327425220),
perName:"",
lastUpdated:null,
engName:"S Mank",
updatedBy:null
},
code:"474747"
}
],
endRow:4,
invalidateCache:false,
isDSResponse:true,
operationType:"fetch",
queueStatus:0,
startRow:0,
status:0,
totalRows:4
}
]
This is my ComboxItem code
bankBranchName = new CustomComboBoxItem()
{
protected Criteria getPickListFilterCriteria()
{
Integer bankid = (Integer) bankName.getValue();
AdvancedCriteria criteria = new AdvancedCriteria("bankid", OperatorId.EQUALS, bankid);
return criteria;
}
};
My BankDS.ds.xml looks like this
<DataSource ID="BankDS" serverType="sql" tableName="Bank">
<fields>
<field name="id" title="Id" type="int" primaryKey="true" />
<field name="engName" title="Name" type="string" />
<field name="perName" title="Persian Name" type="string" />
</fields>
<operationBindings>
<binding operationType="add" serverMethod="add">
<serverObject lookupStyle="new"
className="com.kaizen.erp.server.bussinessLogic.master.BankBussinessLogic" />
</binding>
<binding operationType="update" serverMethod="add">
<serverObject lookupStyle="new"
className="com.kaizen.erp.server.bussinessLogic.master.BankBussinessLogic" />
</binding>
<binding operationType="remove" serverMethod="delete">
<serverObject lookupStyle="new"
className="com.kaizen.erp.server.bussinessLogic.master.BankBussinessLogic" />
</binding>
<binding operationType="fetch" serverMethod="fetch">
<serverObject lookupStyle="new"
className="com.kaizen.erp.server.bussinessLogic.master.BankBussinessLogic" />
</binding>
</operationBindings>
and this is my BankBranchDS.DS.XML code
<DataSource ID="BankBranchDS" serverType="sql" tableName="BankBranch">
<fields>
<field name="id" title="Id" type="int" primaryKey="true" />
<field name="code" title="Code" type="string" />
<field name="perName" title="Persian Name" type="string" />
<field name="bankid" type="text" hidden="true" valueXPath="bank/id" />
<field name="bank" displayField="bank" foreignKey="bank.id" />
</fields>
<operationBindings>
<binding operationType="add" serverMethod="add">
<serverObject lookupStyle="new"
className="com.erp.server.bussinessLogic.master.BankBranchBussinessLogic" />
</binding>
<binding operationType="update" serverMethod="add">
<serverObject lookupStyle="new"
className="com.erp.server.bussinessLogic.master.BankBranchBussinessLogic" />
</binding>
<binding operationType="remove" serverMethod="delete">
<serverObject lookupStyle="new"
className="com.erp.server.bussinessLogic.master.BankBranchBussinessLogic" />
</binding>
<binding operationType="fetch" serverMethod="fetch">
<serverObject lookupStyle="new"
className="com.erp.server.bussinessLogic.master.BankBranchBussinessLogic" />
</binding>
</operationBindings>
Try clearing the value of the Bank Branch Name ComboBoxItem
once a bank is selected.
See the example of how to override getPickListFilterCriteria() called "Dependent Selects (Databound)". It is very similar to what you are trying to do:
http://www.smartclient.com/smartgwt/showcase/#dep_selectects_db_combobox_category