Announcement

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

    setValueMap() doesn't remove selected item

    SmartClient_SNAPSHOT_v90d_2013-06-09


    We have a form that contains a list of field names that a user can select. Every time the form is displayed (via a dialog), the list of field names is updated so we can pick up new formula and summary fields. However, in this particular test case, when selecting a field that has been removed from the grid, the form item still shows the field name.

    My speculation is that the code that sets the value map is not clearing the old value map, or is not detecting that the new value map contains the removed field and updating correctly.

    Note that this particular issue happens only when the user selects the field that will be subsequently removed. The value map is updated correctly when the field is not selected.

    Repro steps:
    [code]
    - Load the test case
    - Create a new formula column
    - Execute the method: openDialog()
    - Observe that formulaField1 is in the list (do not select it)
    - Close the dialog
    - Remove the formula field from the grid
    - Execute the method: openDialog()
    - Observe that formulaField1 is NOT in the list
    - Create another formula column
    - Execute the method: openDialog()
    - Observe that formulaField1 is in the list
    - Select formulaField1
    - Close the dialog
    - Remove the formula field from the grid
    - Execute the method: openDialog()
    - Observe that formulaField1 is STILL in the list

    I have a workaround that involves setting the value of the form item to null before setting the value map, then setting the value back to the first option.

    Code:
    <!DOCTYPE html>
    
    <html>
    <head>
    
        <title >SNTQ-1984</title>
    	
    	 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Core.js"></script>
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Foundation.js"></script>
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Containers.js"></script>
      <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Grids.js"></script>
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Forms.js"></script>
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_DataBinding.js"></script>
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Drawing.js"></script>
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_PluginBridges.js"></script> 
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Charts.js"></script>
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Tools.js"></script>
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/skins/SafetyNetSkin/load_skin.js"></script>
    	
    	
       	<script type="text/javascript" >
    		var isomorphicDir="http://localhost:8080/isomorphic/";
    		
    		var data = [
    			{active:true,inspectorID:12345, region:"United States", state:"Pennsylvania", city:"Pittsburgh", inspections:206,inspections1:206,inspections2:206,inspections3:206,inspections4:206, inspections5:206,inspections6:206,observations:913,lastInspectionDate:Date.parseServerDate(2012,8,14),index:52.6, inspectionType: {id:123, name:"type1"},bodyPartAffectedCodeList:["KNEE", "HEAD"]},
    			{active:true,inspectorID:67890, region:"United States", state:"Pennsylvania", city:"Pittsburgh", inspections:66,inspections1:206,inspections2:206,inspections3:206,inspections4:206,inspections5:206,inspections6:206,observations:0,lastInspectionDate:Date.parseServerDate(2013,1,3),index:75.3, inspectionType: {id:123, name:"type1"},bodyPartAffectedCodeList:["KNEE", "HEAD"]},
    			{active:true,inspectorID:88776, region:"United States", state:"Pennsylvania", city:"Pittsburgh", inspections:66,inspections1:206,inspections2:206,inspections3:206,inspections4:206,inspections5:206,inspections6:206,observations:67,lastInspectionDate:Date.parseServerDate(2012,7,9),index:75.3, inspectionType: {id:123, name:"type1"},bodyPartAffectedCodeList:["KNEE", "HEAD"]},
    			{active:true,inspectorID:44556, region:"United States", state:"Pennsylvania", city:"Pittsburgh", inspections:206,inspections1:206,inspections2:206,inspections3:206,inspections4:206,inspections5:206,inspections6:206,observations:0,lastInspectionDate:Date.parseServerDate(2013,1,4),index:52.6, inspectionType: {id:123, name:"type1"},bodyPartAffectedCodeList:["KNEE", "HEAD"]},
    			{active:false,inspectorID:12345, region:"United States", state:"Pennsylvania", city:"Pittsburgh", inspections:206,inspections1:206,inspections2:206,inspections3:206,inspections4:206,inspections5:206,inspections6:206,observations:913,lastInspectionDate:Date.parseServerDate(2011,5,5),index:52.6, inspectionType: {id:123, name:"type1"}}
    
    		];
    		
    
    	
    		
    
    </script>
    
    </head>
    
    <body>
    This<br>is<br>some<br>text<br>
    	<script type="text/javascript">
    		isc.DataSource.create({
    			ID: "ds",
    			fields: [
    				{name:"inspectorID", title:"Inspector ID", type:"integer" },
    				{name:"active", type:"boolean", title:"Is Active", formatCellValue: function(value, record, rowNum, colNum, grid) { if(value) return "true"; else return false;}},
    				{name:"inspections", type:"integer", title:"Number of Inspections"},
    				{name:"static", type:"text", title:"Really Long Static Field Title"},
    				{name:"region", type:"text", title:"Region/Country"},
    				{name:"state", type:"text", title:"State"},
    				{name:"city", type:"text", title:"City/Municipality", hidden:true},
    				{name:"observations", title:"# Observations", type:"integer"},
    				{name:"lastInspectionDate", type:"date", title:"Last Inspection"},
    				{name:"inspections", type:"integer", title:"Number of Inspections"},
    				{name:"inspections6", type:"integer", title:"Number of Inspections"}
    			],
    			cacheData:data,
    			clientOnly: true
    		});
    		
    		var gridObject = isc.ListGrid.create({
    			dataSource: ds,
    			dataFetchMode : "local",
    			autoFetchData: true,
    			clientOnly: true,
    			width : "50%",
    			autoFitMaxHeight:300,
    			align : "center",
    			autoFitData : "vertical",
    			alternateRecordStyles : true,
    			canAddFormulaFields : true,
    			canAddSummaryFields : true,
    			canGroupBy : true,
    			canReorderFields : true,
    			showGroupSummary : true,
    			groupByMaxRecords : 100,
    			canMultiGroup: true
    
    		});		
    		
    		var getFieldNames = function() {
    			var tmp = [];
    			var fields = gridObject.getAllFields();
    			for(var i=0; i<fields.length; i++)
    				tmp.push(fields[i].name);
    				
    				return tmp;
    		}
    		
    		var form = isc.DynamicForm.create({
    				fields : [ {
    					name : "chartValues",
    					title : "Values (vertical axis)",
    					type : "select",
    					defaultToFirstOption : true
    				} ]
    		});
    		
    		var dialog = isc.Window.create({
    				width : 600,
    				height : 350,
    				title : "Filter Grid",
    				canDragReposition : true,
    				canDragResize : true,
    				padding : 10,
    				autoCenter : true,
    				autoDraw : false,
    				items : [ form ]
    		});
    
    		var openDialog = function() {
    			//form.getItem("chartValues").setValue(null);
    			form.getItem("chartValues").setValueMap(getFieldNames());
    			//form.getItem("chartValues").setValue(getFieldNames()[0]);
    			dialog.show();
    			dialog.redraw();
    		}
    
    	</script>
    </body>
    
    </html>

    #2
    Retested on SmartClient_SNAPSHOT_v91d_2014-02-05_PowerEdition.

    Bumping this old post. As mentioned in my previous post, I have a workaround by setting the form value to null before setting the valueMap. Seems like if an item is selected in the dropdown it is not removed when setting the valueMap.

    Again, very minor issue and I have a workaround. But I just wanted to let you know since you are getting ready to release 9.1

    Comment


      #3
      Whether or not a value will be removed when setValueMap() is called is based on the addUnknownValues setting.

      Comment


        #4
        Thanks for the information!

        Comment

        Working...
        X