Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ComboBox item not filtering data

    Hello there,

    I have problem filtering the CB based on the selection of another CB. What am I doing wrong/missing.Please help.


    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

    Code:
    {
        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

    Code:
    [
        {
            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

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

    and this is my DS.XML code

    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>
    </DataSource>
    Attached Files

    #2
    foreignKey is used to connect two DataSources. What you've got here is just a nested structure with no second DataSource "bank", so that declaration makes no sense.

    We're not sure which field you're actually trying to filter on, but it looks like you want to use valueXPath to make "bankName" a top-level field instead of having it only in the nested structure, then filter on that.

    Also, you've got a useless declaration of a "bankid" field with a valueXPath, when this property already appears at top level in the data.

    Comment


      #3
      Thanks for your feedback.Please help me understand this logic of datasource filtering.

      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 before) which fills the Bank Branch CB.

      My BankDS.ds.xml looks like this

      Code:
      <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>
      </DataSource>
      Now my understanding is in the criterial I mention the field to be searched and then fill on the CB with those data.Please help

      Comment


        #4
        >>Also, you've got a useless declaration of a "bankid" field with a >>valueXPath, when this property already appears at top level in the data.

        By the way this bankid is the id of the bankname which i use to filter from the BankBranchDS.ds.xml. correct me please

        Comment


          #5
          to solve my problem I used hibernate to filter my CB in my business logic code. Like so,
          Code:
          if(StringUtills.isNumber(dsRequest.getFieldValue("bankid"))){
          				criteria.add(Restrictions.eq("bank",new Bank(Integer.parseInt(dsRequest.getFieldValue("bankid").toString()))));
          				criteria_count.add(Restrictions.eq("bank",new Bank(Integer.parseInt(dsRequest.getFieldValue("bankid").toString()))));
          			}

          but want to know is this the most efficient way??????????.please help!!!!

          Comment

          Working...
          X