Announcement

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

    Filtering dependent select lists

    I am having problems with filtering dependent select lists. I created an example that demonstrates the problems that I am having. The example is a variant of the dependent selects example provided in the SDK. It uses data sources and a data model with foreign key constraints, that emulates the data model I have to deal with. I also uses client only data sources in XML format. My data is displayed in a ListGrid, with edit and filters enabled.

    Here are my problems:

    1. When I select a filter value for the Division column, then click the Department select filter for the first time, the values in the Department select are correctly filtered. Then I go back and change the value for the Division filter select. Click the Department select filter a second time and I get all the records in the department datasource (departmentDS).

    2. When I attempt to edit any of the records in the table, the Department select is empty. I have verified that getPickListFilterCriteria() is getting called when clicking the dependent lists in all cases. I am not getting any Javascript errors. I am using version 5.6 (evaluation). See source code with XML data.

    Code:
    	/* File: division.data.xml
    		<List>
    			<division>
    				<divId>1</divId>
    				<desc>Manufacturing</desc>
    			</division>
    			<division>
    				<divId>2</divId>
    				<desc>Marketing</desc>
    			</division>	
    			<division>
    				<divId>3</divId>
    				<desc>Sales</desc>
    			</division>
    			<division>
    				<divId>4</divId>
    				<desc>Services</desc>
    			</division>		
    		</List>		*/
    	
    	/* File: department.data.xml
    		<List>
    			<department>
    				<deptId>10</deptId>
    				<divId>1</divId>
    				<desc>Design</desc>
    			</department>
    			<department>
    				<deptId>11</deptId>
    				<divId>1</divId>
    				<desc>Development</desc>
    			</department>
    			<department>
    				<deptId>12</deptId>
    				<divId>1</divId>
    				<desc>QA</desc>
    			</department>		
    			<department>
    				<deptId>20</deptId>
    				<divId>2</divId>
    				<desc>Advertising</desc>
    			</department>
    			<department>
    				<deptId>21</deptId>
    				<divId>2</divId>
    				<desc>Community Relations</desc>
    			</department>	
    			<department>
    				<deptId>30</deptId>
    				<divId>3</divId>
    				<desc>Channel Sales</desc>
    			</department>
    			<department>
    				<deptId>31</deptId>
    				<divId>3</divId>
    				<desc>Direct Sales</desc>
    			</department>	
    			<department>
    				<deptId>40</deptId>
    				<divId>4</divId>
    				<desc>Consulting</desc>
    			</department>
    			<department>
    				<deptId>41</deptId>
    				<divId>4</divId>
    				<desc>Support</desc>
    			</department>	
    		</List>	*/	
    
    	/* File: employee.data.xml
    	<List>
    		<employee>
    			<emplId>101</emplId>
    			<firstName>George</firstName>
    			<lastName>Washington</lastName>
    			<divId>1</divId>
    			<deptId>10</deptId>
    		</employee>
    		<employee>
    			<emplId>470</emplId>
    			<firstName>Thomas</firstName>
    			<lastName>Jefferson</lastName>
    			<divId>2</divId>
    			<deptId>20</deptId>
    		</employee>
    		<employee>
    			<emplId>335</emplId>
    			<firstName>Theodore</firstName>
    			<lastName>Roosevelt</lastName>
    			<divId>3</divId>
    			<deptId>30</deptId>
    		</employee>
    		<employee>
    			<emplId>321</emplId>
    			<firstName>Abraham</firstName>
    			<lastName>Lincoln</lastName>
    			<divId>4</divId>
    			<deptId></deptId>
    		</employee>			
    	</List>	  */
    	
     	isc.DataSource.create({ 
     		ID:"divisionDS",
     		dataFormat:"xml", 
     		clientOnly: true,
     		fields:{ 
     			divId:{name:"divId", type:"sequence", primaryKey:true}, 
     			desc:{name:"desc"}
     		}, 
     		recordXPath:"//division",
     		dataURL:"testdata/division.data.xml" 
     	})
     		
     	isc.DataSource.create({ 
     		ID:"departmentDS",
     		dataFormat:"xml", 
     		clientOnly: true,
     		fields:{ 
     			deptId:{name:"deptId", type:"sequence", primaryKey:true}, 
     			divId:{name:"divId", foreignKey: "divisionDS.divId"}, 
     			desc:{name:"desc"}
     		}, 
     		recordXPath:"//department", 
     		dataURL:"testdata/department.data.xml"
     	})
     	
        isc.DataSource.create({
        	ID:"employeeDS", 
        	dataFormat:"xml", 
        	clientOnly: true,
        	fields:{ 
        		empId:{name:"Empl ID", type:"sequence", primaryKey:true}, 
        		firstName:{title:"First Name", name:"firstName"}, 
        		lastName:{title:"Last Name", name:"lastName"}, 
        		divId:{title:"Division", name:"divId", foreignKey: "divisionDS.divId"},
        		deptId:{title:"Department", name:"deptId", foreignKey: "departmentDS.deptId"} 
        	},
        	recordXPath:"//employee", 
        	dataURL:"testdata/employee.data.xml" 
        })
     	
    	isc.ListGrid.create({
    		ID:"employeeList",
    		selectionType: "single",
    		dataSource: employeeDS,
    		left: 50, 
    		top: 50,
    		width: 500,
    		height: 150,
    		autoFetchData: true,
    		alternateRecordStyles:true, 
    		showAllRecords:true,
    		showFilterEditor: true,
    		fields: [
    			{name: "emplId", canEdit: false},
    			{name: "firstName"},
    			{name: "lastName"},
    			{name: "divId", canEdit: true,
    				editorType: "select",
    				optionDataSource: divisionDS,
    	    		valueField: "divId",
    	    		displayField: "desc",
    	    		filterEditorType: "select",
    	    		filterEditorProperties: {
    					optionDataSource: divisionDS,
    	    			valueField: "divId",
    	    			displayField: "desc"	    		
    				}
    			},			
    			{name: "deptId", canEdit: true,
    				editorType: "select",
    				optionDataSource: departmentDS,
    	    		valueField: "deptId",
    	    		displayField: "desc",	
    	    		editorProperties: {
    				    getPickListFilterCriteria: function () {
    				        var divComboValue = this.form.getValue('divId');
    				       return {divId: divComboValue};
    			    	}
    			    },		    		
    			    filterEditorType: "select",	    		
    	    		filterEditorProperties: {
    					optionDataSource: departmentDS,
    	    			valueField: "deptId",
    	    			displayField: "desc",		    		
    				    getPickListFilterCriteria: function () {
    				        var divComboValue = this.form.getValue('divId');
    				        return {divId: divComboValue};
    			    	}
    			    }
    			}
    		],
    		canEdit: true,
        	editEvent: "doubleClick"			
    	})

    #2
    Hi Mcaspar3,
    I believe both of these issues are due to bugs in 5.6 that have been resolved in the latest (5.7) build.
    We were able to reproduce the problems in 5.6 but not in 5.7

    Can you try upgrading and let us know if it solves the problem?

    Thanks
    Isomorphic Software

    PS: you can download the 5.7 evaluation build here

    Comment


      #3
      After updating to 5.7, the ListGrid filter works as expected. When editing a row however the dependent list is still not filtering properly. It is showing all records for the department datasource (departmentDS) regardless of what record is selected in the division list. In version 5.6, I was getting an emply department list.

      While testing with version 5.7 I discovered what appears to be a bug. Using the example code, edit one of the first three rows by double clicking the row. Change the value of the department. Then double click on the last row. When I do this all the data rows in the table are duplicated below the last row of the table. This happened a few times when I was testing in version 5.6, but could not figure out how to reproduce it then.

      Comment


        #4
        Ah - after looking a little more carefully at your code I see the problem.
        You're sepecifying clientOnly dataSources, but you're using 'dataURL' to populate them with data - rather than specifying the testData property.
        Our code is actually respecting the dataURL and using it to load data from the server, so this dataSource is being treated as a normal (non-client side) dataSource.
        Therefore the XML response at the dataURL is assumed to have already been filtered on the server.

        Take a look at this documentation for an explanation of how client-only datasources should be populated with data.

        The other bug you're reporting may be an artifact of this same issue - we'll take a look on our end and make sure.

        Thanks
        Isomorphic Software

        Comment


          #5
          Using 'testData' rather than 'dataURL' fixed the filtering of the lists when editing a row (see modified code). The duplicate data row problem however still exists.

          Code:
           	isc.DataSource.create({ 
           		ID:"divisionDS",
           		clientOnly: true,
           		fields:{ 
           			divId:{name:"divId", type:"sequence", primaryKey:true}, 
           			desc:{name:"desc"}
           		}, 
           		testData: <isomorphic:XML filename="testdata/division.data.xml"/>
           	})
           		
           	isc.DataSource.create({ 
           		ID:"departmentDS",
           		clientOnly: true,
           		fields:{ 
           			deptId:{name:"deptId", type:"sequence", primaryKey:true}, 
           			divId:{name:"divId", foreignKey: "divisionDS.divId"}, 
           			desc:{name:"desc"}
           		}, 
           		testData: <isomorphic:XML filename="testdata/department.data.xml"/>
           	})
           	
              isc.DataSource.create({
              	ID:"employeeDS", 
              	clientOnly: true,
              	fields:{ 
              		empId:{name:"Empl ID", type:"sequence", primaryKey:true}, 
              		firstName:{title:"First Name", name:"firstName"}, 
              		lastName:{title:"Last Name", name:"lastName"}, 
              		divId:{title:"Division", name:"divId", foreignKey: "divisionDS.divId"},
              		deptId:{title:"Department", name:"deptId", foreignKey: "departmentDS.deptId"} 
              	},
              	testData: <isomorphic:XML filename="testdata/employee.data.xml"/>
              })

          Comment


            #6
            Looks like your primaryKey field is incorrectly named in the employeeDS DataSource.
            Your data has values for 'emplId', but the field is specified as 'empId', and has a 'name' attribute that doesn't match that value.

            This means that records' primary keys appear to be unset, so after edting they're assumed to be new records.

            Try changing the dataSource field definition as follows:
            Code:
                		emplId:{title:"Empl ID", type:"sequence", primaryKey:true},
            Let us know if this doesn't fix it

            Thanks
            Isomorphic Software

            Comment

            Working...
            X