SmartGWT数据源过滤组合框问题

时间:2014-08-02 08:57:37

标签: gwt smartgwt

我根据另一个CB的选择过滤CB有问题。我做错了什么/失踪。请帮忙。 我有第一个CB获得银行名称,第二个CB根据之前的CB即银行的选择获得银行分行。现在,当用户选择银行名称时,我想过滤第二个CB,即银行分行,以仅显示该银行的相关分支。

我有这个BankDS.ds.xml,第一个CB用来填充银行CB,我有第二个BankBranchDS.ds.xml(代码如下所示),它填满了银行分行CB。

我正在使用此版本SmartClient版本:v8.3p_2014-04-23 / PowerEdition部署(内置于2014-04-23)并在Firefox浏览器版本23上进行测试

这是我的DSRequest输出

{
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
}

这是我的响应输出

[
{
    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
}
]

这是我的ComboxItem代码

    bankBranchName = new CustomComboBoxItem()
    {
        protected Criteria getPickListFilterCriteria()
        {
            Integer bankid = (Integer) bankName.getValue();
            AdvancedCriteria criteria = new AdvancedCriteria("bankid", OperatorId.EQUALS, bankid);
                            return criteria;
        }
    };

我的BankDS.ds.xml看起来像这样

<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>

这是我的BankBranchDS.DS.XML代码

<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>

enter image description here

1 个答案:

答案 0 :(得分:1)

选择银行后,请尝试清除银行分行名称ComboBoxItem的值。

参见如何覆盖名为&#34; Dependent Selects(Databound)&#34;的getPickListFilterCriteria()的示例。它与你想要做的非常相似:
http://www.smartclient.com/smartgwt/showcase/#dep_selectects_db_combobox_category