Announcement

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

    Problem with formula field visibility

    Hello,

    We are seeing a problem with formula field visibility when changing view states on a grid. We are seeing the problem in both 8.2 and 8.3 recent nightly SDKs. Oddly enough, is not showing up in your online showcase but I'm not sure what version is running there.

    So, go to this Custom Columns example in your SDK: system/reference/SmartClient_Explorer.html#customColumns

    Use this code
    Code:
    
    var ds = isc.DataSource.get("countryDS");
    
    isc.VLayout.create({
    	ID:"layout",
    	width:500, height:250,
    	members: [
    		isc.HLayout.create({
    			ID:"buttonLayout",
    			width:"*", height:30,
    			membersMargin: 10,
    			members: [
    				isc.IButton.create({
    				    ID: "formulaButton",
    				    autoFit: true,
    				    title: "Show Formula Builder",
    				    click: "countryList.addFormulaField();"
    				}),
    				isc.IButton.create({
    				    ID: "summaryButton",
    				    autoFit: true,
    				    title: "Show Summary Builder",
    				    click: "countryList.addSummaryField();"
    				}),
    				isc.IButton.create({
    				    ID: "getStateButton",
    				    autoFit: true,
    				    title: "Send State to Console",
    				    click: "isc.Log.logInfo(countryList.getViewState())"
    				}),
    				isc.IButton.create({
    				    ID: "applyStateButton",
    				    autoFit: true,
    				    title: "Change to Alernate State",
    				    click: "countryList.setViewState(countryList.alternateState);"
    				}),
    				isc.IButton.create({
    				    ID: "stateButton",
    				    autoFit: true,
    				    title: "Recreate from State",
    				    click: function () {
    				        var state = countryList.getFieldState(true);
    						countryList.destroy();
    						recreateListGrid();
    				        countryList.setFieldState(state);
    				    }
    				})
    			]
    		})
    	]
    });
    
    
    
    recreateListGrid();
    
    
    
    
    
    function recreateListGrid() {
    	layout.addMember(isc.ListGrid.create({
    	    ID: "countryList",
    	    width:"100%", height:"*",
    	    alternateRecordStyles:true, cellHeight:22,
    	    dataSource: ds,
    	    autoFetchData: true,
    alternateState: {selected:"[]",field:"[{name:\"countryCode\",visible:false,width:null,autoFitWidth:null},{name:\"countryName\",visible:false,width:null,autoFitWidth:null},{name:\"capital\",visible:false,width:null,autoFitWidth:null},{name:\"population\",width:null,autoFitWidth:null},{name:\"area\",width:null,autoFitWidth:null},{name:\"gdp\",width:null,autoFitWidth:null}]",sort:"({fieldName:null,sortDir:\"ascending\"})",hilite:null,group:""},
    
    	    canAddFormulaFields: true,
    	    canAddSummaryFields: true,
    	    fields:[
    	        {name:"countryCode", title:"Flag", width:50, type:"image", imageURLPrefix:"flags/16/", 
    	            imageURLSuffix:".png"
    	        },
    	        {name:"countryName", title:"Country"},
    	        {name:"capital", title:"Capital"},
    	        {name:"population", title:"Population", formatCellValue:"isc.Format.toUSString(value)"},
    	        {name:"area", title:"Area (km²)", formatCellValue:"isc.Format.toUSString(value)"},
    	        {name:"gdp", formatCellValue:"isc.Format.toUSString(value)"}
    	    ]
    	}));
    
    }
    
    
    countryList.setViewState({selected:"[]",field:"[{name:\"countryCode\",width:50,autoFitWidth:null},{name:\"countryName\",width:null,autoFitWidth:null},{name:\"capital\",width:null,autoFitWidth:null},{name:\"population\",width:null,autoFitWidth:null},{name:\"area\",width:null,autoFitWidth:null},{name:\"gdp\",width:null,autoFitWidth:null},{name:\"formulaField1\",visible:false,userFormula:{text:\"A\",formulaVars:{A:\"population\"}},title:\"New Field\",width:null,autoFitWidth:null}]",sort:"({fieldName:null,sortDir:\"ascending\"})",hilite:null,group:""});
    When you click Try it, you can see that a hidden Formula Field has been added by looking at the column menu. Now, click the "Change to Alternate State" button. This button loads a second view state that has no information about the formula field saved in it's state. As a result, the grid starts displaying the formula field changing it from hidden to visible. It would seem the correct behavior would be to not change the visibility of the formula field in this case.

    #2
    We agree - this is incorrect and have made a change to fix it.

    Regards
    Isomorphic Software

    EDIT: The fix will be present in the next nightly 8.2d build

    Comment

    Working...
    X