Announcement

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

    Another difference with summary calculations between 8.2 and 8.3

    Hi, this is a second difference between 8.2 and 8.3 related to summary calculations after the first one I just posted. It appears that formatCellValue is not recognizing that the current record is a grid Summary record.

    See the sample below. Run it in 8.2 and the Scientific Name summary is blank. Run it in 8.3 and it shows as "NA". But, if you look at the logic in the formatString function being applied to Scientific Name it shouldn't be showing as "NA".

    Code:
    <%@ taglib uri="/WEB-INF/iscTaglib.xml" prefix="isomorphic" %>
    <HEAD>
    
    <TITLE>
            SmartClient SDK - Animal Data Binding example
    </TITLE>
    
    <style>
    
    input.file {
    	position: relative;
    	text-align: right;
    	-moz-opacity:0 ;
    	filter:alpha(opacity: 0);
    	opacity: 0;
    	z-index: 2;
    color:#CCCCCC;
    
    }
    
    .uploadControl{
    width:500px;
    color:#CCCCCC;
    }
    
    </style>
    
    </HEAD><isomorphic:loadISC skin="SmartClient"/>
    <BODY BGCOLOR=#D3D3D3>
    
    <SCRIPT>
    
    
    <isomorphic:XML>
    <jsp:include page="../shared/ds/animals.ds.xml"></jsp:include>
    </isomorphic:XML>
    
    
    
    
    
    
    	var faDS = isc.DataSource.getDataSource("animals");
    	faDS.addMethods({
    
    
        fetchData : function (record, callback, requestProperties) {
            if (requestProperties == null) requestProperties = {};
            //do not use this short fetch below here for FundAsset
            //if (requestProperties.timeout == null) requestProperties.timeout = 1000;
            if (requestProperties.prompt == null) requestProperties.prompt = "fetching1_test";
            return this.Super("fetchData", [record, callback, requestProperties]);
        },
        updateData : function (record, callback, requestProperties) {
            if (requestProperties == null) requestProperties = {};
            if (requestProperties.prompt == null) requestProperties.prompt = "saving_test";
            if (requestProperties.timeout == null) requestProperties.timeout = 2000
            return this.Super("updateData", [record, callback, requestProperties]);
        },
        addData : function (record, callback, requestProperties) {
            if (requestProperties == null) requestProperties = {};
            if (requestProperties.prompt == null) requestProperties.prompt = "adding_test";
            if (requestProperties.timeout == null) requestProperties.timeout = 2500;
            return this.Super("addData", [record, callback, requestProperties]);
        },
    
    
        transformRequest : function (dsRequest) {
          
          dsRequest.data = stripDSFields(dsRequest.data, faDS.fields,true,true,false);
          dsRequest.oldValues = stripDSFields(dsRequest.oldValues, faDS.fields,true,true,false);
    
          var params = {
                  cvsTag : "cvsTag_1",
                  browser:"Firefox",
                  browserVersion:"3.6",
                  browserOS:"Windows",
                  requestUserID: 1,
                  departmentID: 2,
                  companyID:3
               };
    
    
    	if(isc.getValueForKey("test1ID",dsRequest.data)=="test1ID" ){
    		params.test1ID=14;
    	}
    	if(isc.getValueForKey("test2ID",dsRequest.data)=="test2ID" ){
    		params.test2ID=28;
    	}
    
    	if(isc.getValueForKey("test3ID",dsRequest.data)=="test3ID" ){
    
    		if(at.initialLayoutComplete){
    			params.test3ID=28;
    		}else{
    			params.test3ID=null;
    		}
    	}
    
    
    
    
    	  return isc.addProperties({}, dsRequest.data, params);
        }
    	})	
    
    
    var at={};
    
    isc.setAutoDraw(false);
    
    	isc.Window.addProperties({
    		showHeaderBackground:false,
    		//canDragResize:true,
    		//showFooter:true,
    		//showResizer:true,
    		autoDraw: false,
            autoCenter: true,
            autoSize: true,
            dismissOnEscape: true,
            showCloseButton: true,
            showMinimizeButton: true
    	})
    
    var demoApp={};
    
    isc.HTMLFlow.create({
        	ID:"animalMessage",
        	padding:10,
            width:650,
        	contents:"Animal Details"
    		});
    
    
    isc.HTMLFlow.create({
        	ID:"animalMessage2",
        	padding:10,
        	contents:"Animal Details"
    		});
    
    isc.HTMLFlow.create({
        	ID:"animalMessage3",
        	padding:10,
        	contents:"Animal Details"
    		});
    
    isc.HTMLFlow.create({
        	ID:"animalMessage4",
        	padding:10,
        	contents:"Animal Details"
    		});
    
    isc.HTMLFlow.create({
        	ID:"animalMessage5",
        	padding:10,
        	contents:"Animal Details"
    		});
    
    isc.HTMLFlow.create({
        	ID:"animalMessage6",
        	padding:10,
        	contents:"Animal Details"
    		});
    
    isc.HTMLFlow.create({
        	ID:"animalMessage7",
        	padding:10,
        	contents:"Animal Details<br/><a style='display:inline' href='#' onclick='showAssetNotesWindow(null,true,null);' title='add notes'>add notes</a>"
    		});
    
    
    isc.DynamicForm.create({ID:"assetNotesEditor",
    overflow: "auto",
    fields:[{name:"assetID", type:"select",width:150,allowEmptyValue:false,colSpan:3, title:"asset",prompt:"prompt"},{name:"subject", cellStyle:"uploadControl",colSpan:3,width:150, prompt:"subject"},{name:"source", colSpan:3,width:150, prompt:"source"},{name:"attachedFile",title:"attachment",type:"binary",cellStyle:"uploadControl", prompt:"attachment test"},{name:"notes", showTitle:true, colSpan:3,height:375,width:"*", prompt:"notes"}],itemHoverAlign:"left",itemHoverHeight:100,itemHoverWidth:200,height:465,numCols:4,width:700,colWidths:[100,80,80,"*"]});
    
    
    isc.DynamicForm.create({ID: "assetNotesWindowSave",numCols:4,width:"650",height:"25",itemHoverAlign:"left",itemHoverHeight:100,itemHoverWidth:200,colWidths:[100,120,80,"*"]});
    
    
    
    function showAssetNotesWindow(record,add,assetID){
    
    
    
    	
    	if(at.assetNotesWindow==null || !at.assetNotesWindow.isVisible() || !at.assetNotesWindow.isDrawn()){
    
    		if(at.assetNotesWindow==null){
    			var windowTitle = "notes";
    			at.assetNotesWindow = isc.Window.create({
    				title: windowTitle,
    				items: [ assetNotesEditor,assetNotesWindowSave ]
       	 		});
          		 
    		}
    
    	}
    	
    	
    	assetNotesEditor.markForRedraw();
    	at.assetNotesWindow.show();
    	at.assetNotesWindow.bringToFront();
    	
    }
    
    isc.HTMLFlow.create({
        	ID:"animalMessage8",
        	padding:10,
        	contents:"Animal Details"
    		});
    
    isc.HTMLFlow.create({
        	ID:"animalMessage9",
        	padding:10,
        	contents:"Animal Details"
    		});
    
    isc.DynamicForm.create({
    	ID: "animalGamesSummary",
    	itemHoverAlign:"left",
    	itemHoverHeight:100,
    	itemHoverWidth:200,
      	editEvent:"click",
    	overflow: "auto",
    	emptyMessage:"empty"
    });
    
    function updateAnimalGamesSummary() {
    
    	animalGamesSummaryFields = [
     		{type:"rowSpacer", height:10},
    		{name:"animalSummary"}
     	];
    	animalGamesSummary.setFields(animalGamesSummaryFields);
    
    
    }
    
    isc.DynamicForm.create({
    	title:"Games Editor",
    	ID:"animalGamesEditor",
      	overflow: "auto",
      	itemHoverAlign:"left",
    	itemHoverHeight:100,
    	itemHoverWidth:200,
        emptyMessage:"empty"
    });
    
    function updateAnimalGamesEditor() {
    
    	animalGamesEditorFields = [
     		{type:"rowSpacer", height:10},
    		{name:"animalGamesEditor"}
     	];
    	animalGamesEditor.setFields(animalGamesEditorFields);
    
    
    }
    
    isc.DynamicForm.create({
    	title:"Data",
    	ID:"animalDataEditor",
      	overflow: "auto",
      	itemHoverAlign:"left",
    	itemHoverHeight:100,
    	itemHoverWidth:200,
        emptyMessage:"empty"
    });
    
    function updateAnimalDataEditor() {
    
    	animalDataEditorFields = [
     		{type:"rowSpacer", height:10},
    		{name:"attachedFile",type:"binary"},
    		{name:"animalDataEditor"}
     	];
    	animalDataEditor.setFields(animalDataEditorFields);
    
    }
    
    isc.HLayout.create({
    	ID:"animalGamesSummaryLayout", 
    	members:[
            animalGamesSummary,
            animalGamesEditor,
            animalDataEditor
        ]
    });
    
     isc.DynamicForm.create({
     	ID: "animalGamesSave",
    	autoDraw:false,
    	numCols:5,
    	width:"100%",
    	itemHoverAlign:"left",
    	itemHoverHeight:100,
    	itemHoverWidth:200,
    	colWidths:[80,80,80,80,"*"]
     });
    
     function updateAnimalGamesSave(){
     	animalGamesSaveFields=[
    
       	  	{type:"button",  cellPadding:0,  startRow:false,endRow: false,prompt:"edit",title:"Edit", showTitle:false, showLabel:false},
       	  	{type:"button",  cellPadding:0,  startRow:false,endRow: false,prompt:"edit",title:"Add", showTitle:false, showLabel:false, click:"animalGamesGrid.startEditingNew();"}
    
        ];
      
        animalGamesSave.setFields(animalGamesSaveFields);
     
     }
    
    isc.ListGrid.create({
    	ID:"animalGamesGrid",
    	headerHeight:36,
    	height:125,
    	canHover:true,
    	hoverWidth:150,
    	hoverHeight:50,
    	hoverAlign:"left",
    	hoverVAlign:"center",
    	canSort:false,
    	stopOnErrors:true,
    	headerButtonProperties:{
            hoverWidth:200, hoverHeight:100, hoverAlign:"left", hoverVAlign:"center"
        },
    	listEndEditAction:"next",
    	autoSaveEdits:false,
    	editEvent:"click",
    	emptyMessage:"empty",
    	alternateRecordStyles: true,
    
    	fields:[
                {name:"lifeSpan", width:50,canEdit:true,formatCellValue:"if(grid == animalGamesGrid) return formatNumber(value,0,'years','after',false)" },
    		{name:"gameName",  canEdit:true, prompt:"Game"}
    
    	]
    })
    
    isc.SectionStack.create({
    	ID:"animalGamesSections", 
    	className:"borderBR",
        visibilityMode:"multiple", 
        backgroundColor:"white",
    	sections:[
        	{ expanded:true, items:[animalGamesGrid],showHeader:false},
        	{ expanded:true, items:[animalGamesSave],showHeader:false},
    	{ expanded:true, items:[animalGamesSummaryLayout],showHeader:false}
        ]
    });
    
    isc.SearchForm.create({
        cellPadding:4,
        numCols:8,
    	itemHoverAlign:"left",
    	itemHoverHeight:100,
    	itemHoverWidth:200,
        ID:"findAnimalsForm"
    })
    
    function showQuickAddGrid(){
    	
    	    updateQuickAddGrid(); 
    
    	if(demoApp.quickAddWindow==null || !demoApp.quickAddWindow.isVisible() || !demoApp.quickAddWindow.isDrawn()){
     
    	     demoApp.quickAddWindow = isc.Window.create({
                title: "quick add",
                items: [ quickAddGrid ]
            });
    
    		quickAddGrid.setData([]); 
    
    
    	demoApp.quickAddWindow.show();
       	demoApp.quickAddWindow.bringToFront();
    	quickAddGrid.cancelEditing();
    	quickAddGrid.discardAllEdits();
    	quickAddGrid.markForRedraw();
    	quickAddGrid.delayCall("focus");
    	quickAddGrid.delayCall("startEditingNew");
    
        }
        
    
    
    }
    
    
    //handles getting the grid's data whether the grid is grouped or ungrouped
    function getGridDataSet(grid,invalidateCache, useOriginalData, checkIfAllDataLoaded){
    	
    	if(grid==null){
    		return null;
    	}
    	
    	var dataSet=grid.data;
    	if( ( useOriginalData==null ||useOriginalData) && grid.isGrouped && grid.originalData!=null){
    		dataSet=grid.originalData;
    	}
    	
    	var dataLoaded = false;
    	var allDataLoaded=false;
    	var dataSetLength;
    
    	if(grid.isGrouped){
    		if(grid.originalData!=null){
    			dataLoaded = isA.Function(grid.originalData.lengthIsKnown) && grid.originalData.lengthIsKnown();
    			
    			if(dataLoaded){
    				//isc.Log.logInfo("in getGridDataSet, checking dataSetLength and rangeIsLoaded on grid.originalData");
    				dataSetLength = grid.originalData.getLength();
    				allDataLoaded = isA.Function(grid.originalData.rangeIsLoaded) &&  grid.originalData.rangeIsLoaded(0, dataSetLength);
    			}
    		}
    	}else{
    		if(grid.data!=null){
    			dataLoaded = isA.Function(grid.data.lengthIsKnown) && grid.data.lengthIsKnown();
    			
    			if(dataLoaded){
    				//isc.Log.logInfo("in getGridDataSet, checking dataSetLength and rangeIsLoaded on grid.data");
    				dataSetLength = grid.data.getLength();
    				allDataLoaded = isA.Function(grid.data.rangeIsLoaded) &&  grid.data.rangeIsLoaded(0, dataSetLength);
    			}
    		}
    	}
    	
    
    	
    	if(invalidateCache && dataSet!=null && dataSet!=''){
    
    
    		if(allDataLoaded){
    			
    			//data is loaded, now we check whether the entire range is loaded to determine
    			//if we can safely invalidate
    
    				if(grid.isGrouped){
    					//isc.Log.logInfo("in getGridDataSet invalidating cache, calling ungroup");
    					grid.ungroup();
    				}
    				//isc.Log.logInfo("in getGridDataSet, calling invalidateCache");
    				dataSet.invalidateCache();
    				//isc.Log.logInfo("in getGridDataSet invalidating cache done");
    
    		}
    		
    
    	}
    	
    	if((checkIfAllDataLoaded==null || checkIfAllDataLoaded) && !allDataLoaded){
    		//isc.Log.logInfo("all data not loaded, returning null");
    		dataSet=null;
    	}
    
    	return dataSet;
    	
    }
    
    
    
    isc.Menu.create({
    	ID:"animalMenu",
    	showKeys:true,
    	data:[
    		{title:"Add", click:function () {showQuickAddGrid();}}
        
        ]
    });
    
    ListGrid.create({
                ID:"animalsGrid",
    	    noSummaryFunctions:getGridNoSummaryFunctions(),
    	    showGridSummary:true,
                showGroupSummary:true,
                dataSource:"animals",
    		canEdit:false,
                contextMenu:animalMenu,
    		virtualScrolling:false,
        		selectionType:"none",
        		recordClick : function (viewer, record, recordNum, field, fieldNum, value, rawValue) {
        			nextRecord=record;
    			showDetails();
        		}, 
           	headerHeight: 36
            })
    
    isc.ListGrid.create({
        ID: "quickAddGrid",
        headerHeight: 36,
        height:400,
    width:400,
    	listEndEditAction:"next",
    	canSort:false,
    	canHover:true,
    	hoverWidth:150,
    	hoverHeight:50,
    	hoverAlign:"left",
    	hoverVAlign:"center",
    	stopOnErrors:true,
    	canEdit:false,
    	headerButtonProperties:{
            hoverWidth:200, hoverHeight:100, hoverAlign:"left", hoverVAlign:"center"
        },
    	canEdit:true,
    	autoSize: true,
    	autoSaveEdits:true,
    	alternateRecordStyles: true,
    
    	editComplete:function(rowNum,colNum,newValues,oldValues,editCompletionEvent,dsResponse){
    
        		var dataSet = getGridDataSet(animalsGrid);
    		isc.Timer.setTimeout("quickAddGrid.startEditingNew();",0);
    			
    	},    
        dataSource:animals
    });
    
    isc.TabSet.create({
    	ID:"animalTabs",
    	height:380,
    	tabs:[
    		{title:"Games", pane:animalMessage, ID:"animalGamesTab", width:70},
    		{title:"Notes", pane:animalMessage, ID:"animalNotesTab", width:70},
    		{title:"Food", pane:animalMessage, ID:"animalFoodTab", width:70},
    		{title:"Details", pane:animalMessage, ID:"animalDetailsTab", width:70}
    
    	]
    });
    
    <%-- right-side layout--%>
    isc.SectionStack.create({
    	ID:"rightSections", 
    	overflow:"auto",
    	className:"borderBR",
        visibilityMode:"multiple", backgroundColor:"white",
    	sections:[
          {title:"View Options", expanded:true,resizeable:false, items:[{children:[findAnimalsForm],height:30}]},      			
        	{title:"Grid", canCollapse:false, expanded:true, items:[animalsGrid]},
        	{title:"Detail", resizeable:false,  expanded:true, items:[animalTabs]} ,
    	{title:"Welcome", canCollapse:false,expanded:true, items:[animalMessage6]}
       ]
    });
    
    <%-- fund sections--%>
    isc.SectionStack.create({ID:"animalProfileSections", className:"borderBR",
        visibilityMode:"multiple", backgroundColor:"white",
    	sections:[
        	{ expanded:true, items:[animalMessage2],showHeader:false},
        	{ expanded:true, items:[animalMessage3],showHeader:false}
    	]
    })
    
    <%-- left-side layout--%>
    isc.SectionStack.create({ID:"leftSections",
        showResizeBar:true, visibilityMode:"multiple", width:250, className:"borderBL",
    	sections:[
        	{title:"Left", canCollapse:false, expanded:true, items:[animalProfileSections]}
    	]
    })
    
    <%-- **************overall page layout ************************--%>
    isc.VLayout.create({
    	ID:"pageLayout", 
    	width:"100%", 
    	height:"100%", 
    	members:[
        	animalMessage4,
        	isc.HLayout.create({
        		ID:"mainLayout", 
        		layoutMargin:5, 
        		members:[
            		leftSections,
            		rightSections
        		]
        	})
    	]
    });
    
    function showDetails() {
    
    	var record = nextRecord;
    	if(!rightSections.sectionIsExpanded(2) ){
    	    isc.Timer.setTimeout(
              "rightSections.expandSection(2);",
            0
        	);
    	}
    
       	animalTabs.updateTab(animalTabs.getTabObject("animalGamesTab"),animalGamesSections);
    	animalTabs.updateTab(animalTabs.getTabObject("animalNotesTab"),animalMessage7);
     	animalTabs.updateTab(animalTabs.getTabObject("animalFoodTab"),animalMessage8);
    	animalTabs.updateTab(animalTabs.getTabObject("animalDetailsTab"),animalMessage9);
    
        isc.Timer.setTimeout(
            "animalsGrid.scrollRecordIntoView(" + animalsGrid.getRecordIndex(record) + ")",
            0
        );
    
    }
    
    
    //helper method to copy object properties from one object to another--%>
    function copyObjectProperties(originObj,destObj, dataSourceName){
    	
    	if(destObj==null){
    		destObj={};
    	}
    	var originKeys = isc.getKeys(originObj);
    
    
    	var j = originKeys.length;
    	for (var i = 0; i < j; i++){
    		var key = originKeys[i];
    		//append test to cause value to change
    		destObj[key] = originObj[key] + " test"
    	}
    }
    
    
    function updateGridData(){
    
    		var record = animalsGrid.getRecord(1);
    		record.lifeSpan2 = record.lifeSpan*2;
    		record.continent1="test data";
    		record.continent2="test data";
    		record.continent3="test data";
    		record.continent4="test data";
    		record.continent5="test data";
    		record.continent6="test data";
    		record.continent7="test data";
    		record.continent8="test data";
    		record.continent9="test data";
    		record.continent10="test data";
    		record.continent11="test data";
    		record.continent12="test data";
    		record.continent13="test data";
    		record.continent14="test data";
    		record.continent15="test data";
    		record.continent16="test data";
    		record.continent17="test data";
    		record.continent18="test data";
    		record.continent19="test data";
    		record.continent20="test data";
    		record.continent21="test data";
    		record.continent22="test data";
    		record.continent23="test data";
    		record.continent24="test data";
    		record.continent25="test data";
    		record.continent26="test data";
    		record.continent27="test data";
    		record.continent28="test data";
    		record.continent29="test data";
    		record.continent30="test data";
    		record.continent31="test data";
    		record.continent32="test data";
    		record.continent33="test data";
    		record.continent34="test data";
    		record.continent35="test data";
    		record.continent36="test data";
    		record.continent37="test data";
    		record.continent38="test data";
    		record.continent39="test data";
    		record.continent40="test data";
    		record.continent41="test data";
    		record.continent42="test data";
    		record.continent43="test data";
    		record.continent44="test data";
    		record.continent45="test data";
    		record.continent46="test data";
    		record.continent47="test data";
    		record.continent48="test data";
    		record.continent49="test data";
    		record.continent50="test data";
    		record.continent51="test data";
    		record.continent52="test data";
    		record.continent53="test data";
    		record.continent54="test data";
    		record.continent55="test data";
    		record.continent56="test data";
    		record.continent57="test data";
    		record.continent58="test data";
    		record.continent59="test data";
    		record.continent60="test data";
    		record.continent61="test data";
    		record.continent62="test data";
    		record.continent63="test data";
    		record.continent64="test data";
    		record.continent65="test data";
    		record.continent66="test data";
    		record.continent67="test data";
    		record.continent68="test data";
    		record.continent69="test data";
    		record.continent70="test data";
    		record.continent71="test data";
    		record.continent72="test data";
    		record.continent73="test data";
    		record.continent74="test data";
    		record.continent75="test data";
    		record.continent76="test data";
    		record.continent77="test data";
    		record.continent78="test data";
    		record.continent79="test data";
    		record.continent80="test data";
    		record.continent81="test data";
    		record.continent82="test data";
    		record.continent83="test data";
    		record.continent84="test data";
    		record.continent85="test data";
    		record.continent86="test data";
    		record.continent87="test data";
    		record.continent88="test data";
    		record.continent89="test data";
    		record.continent90="test data";
    		record.continent91="test data";
    		record.continent92="test data";
    		record.continent93="test data";
    		record.continent94="test data";
    		record.continent95="test data";
    		record.continent96="test data";
    		record.continent97="test data";
    		record.continent98="test data";
    		record.continent99="test data";
    		record.continent90="test data";
    		record.continent91="test data";
    		record.continent92="test data";
    		record.continent93="test data";
    		record.continent94="test data";
    		record.continent95="test data";
    		record.continent96="test data";
    		record.continent97="test data";
    		record.continent98="test data";
    		record.continent99="test data";
    		record.continent100="test data";
    		record.continent101="test data";
    		record.continent102="test data";
    		record.continent103="test data";
    		record.continent104="test data";
    		record.continent105="test data";
    		record.continent106="test data";
    		record.continent107="test data";
    		record.continent108="test data";
    		record.continent109="test data";
    		record.continent110="test data";
    		record.continent111="test data";
    		record.continent112="test data";
    		record.continent113="test data";
    		record.continent114="test data";
    		record.continent115="test data";
    		record.continent116="test data";
    		record.continent117="test data";
    		record.continent118="test data";
    		record.continent119="test data";
    		record.continent120="test data";
    		record.continent121="test data";
    		record.continent122="test data";
    		record.continent123="test data";
    		record.continent124="test data";
    		record.continent125="test data";
    		record.continent126="test data";
    		record.continent127="test data";
    		record.continent128="test data";
    		record.continent129="test data";
    		record.continent130="test data";
    		record.continent131="test data";
    		record.continent132="test data";
    		record.continent133="test data";
    		record.continent134="test data";
    		record.continent135="test data";
    		record.continent136="test data";
    		record.continent137="test data";
    		record.continent138="test data";
    		record.continent139="test data";
    		record.continent140="test data";
    		record.continent141="test data";
    		record.continent142="test data";
    		record.continent143="test data";
    		record.continent144="test data";
    		record.continent145="test data";
    		record.continent146="test data";
    		record.continent147="test data";
    		record.continent148="test data";
    		record.continent149="test data";
    		record.continent150="test data";
    		record.continent151="test data";
    		record.continent152="test data";
    		record.continent153="test data";
    		record.continent154="test data";
    		record.continent155="test data";
    		record.continent156="test data";
    		record.continent157="test data";
    		record.continent158="test data";
    		record.continent159="test data";
    
    
    		var record2 = isc.clone(record);
    
    		copyObjectProperties(record2,record);
    }
    
    function updateFindAnimalsForm(){
        	findAnimalsForm.setFields(
    		[
        	{type:"staticText", showIf:" return false;",shouldSaveValue:false},
          {name:"search"},
    	{type: "button",  showIf:" return false;",width:200, title:"Ungroup, No Update,  Redraw",click:function(){
    
    		isc.say("redrawing...");
    		if(animalsGrid.isGrouped){
    			animalsGrid.ungroup();
    		}
    		//do not call updateGridData here
    		//updateGridData();
    		animalsGrid.redraw();
    		isc.say('redraw complete');
    		}
    	},
    	{type: "button",  showIf:" return false;",width:200, title:"Ungroup, Update, and Redraw",click:function(){
    
    		isc.say("updating data and redrawing...");
    		if(animalsGrid.isGrouped){
    			animalsGrid.ungroup();
    		}
    		//call updateGridData here which causes
    		updateGridData();
    		animalsGrid.redraw();
    		isc.say('updating data and redraw complete');
    		}
    	},
    	{type: "button", showIf:" return false;", width:200, title:"Group, Update, Redraw",click:function(){
    
    		isc.say("grouping, updating data, and redrawing...");
    		if(!animalsGrid.isGrouped){
    			animalsGrid.groupBy("information");
    		}
    		//call updateGridData here which causes
    		updateGridData();
    		animalsGrid.redraw();
    		isc.say('group, updating data, and redraw complete');
    		}
    	}
    		]
    		);
    
    
    }
    
    function updateAnimalsGrid(){
    
    	var animalsGridFields=[
    		{name:"commonName"},
                {name:"scientificName", showGridSummary:true,showGroupSummary:true,formatCellValue:function (value, record, rowNum, colNum) {
    	   	    if(record!=null){
    	           return formatString(record,value);
        		}}},
                {name:"lifeSpan", formatCellValue:function (value, record, rowNum, colNum) {
    	   	    if(record!=null){
    	           return formatNumber(record,value);
        		}}},
                {name:"lifeSpan2",showGridSummary:true,showGroupSummary:true, type:"float"},
                {name:"information"},
                {name:"information2", showIf:"return false;"},
            {name:"continent1", showIf:"return false;"},
            {name:"continent2", showIf:"return false;"},
            {name:"continent3", showIf:"return false;"},
            {name:"continent4", showIf:"return false;"},
            {name:"continent5", showIf:"return false;"},
            {name:"continent6", showIf:"return false;"},
            {name:"continent7", showIf:"return false;"},
            {name:"continent8", showIf:"return false;"},
            {name:"continent9", showIf:"return false;"},
            {name:"continent10", showIf:"return false;"},
            {name:"continent11", showIf:"return false;"},
            {name:"continent12", showIf:"return false;"},
            {name:"continent13", showIf:"return false;"},
            {name:"continent14", showIf:"return false;"},
            {name:"continent15", showIf:"return false;"},
            {name:"continent16", showIf:"return false;"},
            {name:"continent17", showIf:"return false;"},
            {name:"continent18", showIf:"return false;"},
            {name:"continent19", showIf:"return false;"},
            {name:"continent20", showIf:"return false;"},
            {name:"continent21", showIf:"return false;"},
            {name:"continent22", showIf:"return false;"},
            {name:"continent23", showIf:"return false;"},
            {name:"continent24", showIf:"return false;"},
            {name:"continent25", showIf:"return false;"},
            {name:"continent26", showIf:"return false;"},
            {name:"continent27", showIf:"return false;"},
            {name:"continent28", showIf:"return false;"},
            {name:"continent29", showIf:"return false;"},
            {name:"continent30", showIf:"return false;"},
            {name:"continent31", showIf:"return false;"},
            {name:"continent32", showIf:"return false;"},
            {name:"continent33", showIf:"return false;"},
            {name:"continent34", showIf:"return false;"},
            {name:"continent35", showIf:"return false;"},
            {name:"continent36", showIf:"return false;"},
            {name:"continent37", showIf:"return false;"},
            {name:"continent38", showIf:"return false;"},
            {name:"continent39", showIf:"return false;"},
            {name:"continent40", showIf:"return false;"},
            {name:"continent41", showIf:"return false;"},
            {name:"continent42", showIf:"return false;"},
            {name:"continent43", showIf:"return false;"},
            {name:"continent44", showIf:"return false;"},
            {name:"continent45", showIf:"return false;"},
            {name:"continent46", showIf:"return false;"},
            {name:"continent47", showIf:"return false;"},
            {name:"continent48", showIf:"return false;"},
            {name:"continent49", showIf:"return false;"},
            {name:"continent50", showIf:"return false;"},
            {name:"continent51", showIf:"return false;"},
            {name:"continent52", showIf:"return false;"},
            {name:"continent53", showIf:"return false;"},
            {name:"continen534", showIf:"return false;"},
            {name:"continent55", showIf:"return false;"},
            {name:"continent56", showIf:"return false;"},
            {name:"continent57", showIf:"return false;"},
            {name:"continent58", showIf:"return false;"},
            {name:"continent59", showIf:"return false;"},
            {name:"continent60", showIf:"return false;"},
            {name:"continent61", showIf:"return false;"},
            {name:"continent62", showIf:"return false;"},
            {name:"continent63", showIf:"return false;"},
            {name:"continent64", showIf:"return false;"},
            {name:"continent65", showIf:"return false;"},
            {name:"continent66", showIf:"return false;"},
            {name:"continent67", showIf:"return false;"},
            {name:"continent68", showIf:"return false;"},
            {name:"continent69", showIf:"return false;"},
            {name:"continent70", showIf:"return false;"},
            {name:"continent71", showIf:"return false;"},
            {name:"continent72", showIf:"return false;"},
            {name:"continent73", showIf:"return false;"},
            {name:"continent74", showIf:"return false;"},
            {name:"continent75", showIf:"return false;"},
            {name:"continent76", showIf:"return false;"},
            {name:"continent77", showIf:"return false;"},
            {name:"continent78", showIf:"return false;"},
            {name:"continent79", showIf:"return false;"},
            {name:"continent80", showIf:"return false;"},
            {name:"continent81", showIf:"return false;"},
            {name:"continent82", showIf:"return false;"},
            {name:"continent83", showIf:"return false;"},
            {name:"continent84", showIf:"return false;"},
            {name:"continent85", showIf:"return false;"},
            {name:"continent86", showIf:"return false;"},
            {name:"continent87", showIf:"return false;"},
            {name:"continent88", showIf:"return false;"},
            {name:"continent89", showIf:"return false;"},
            {name:"continent90", showIf:"return false;"},
            {name:"continent91", showIf:"return false;"},
            {name:"continent92", showIf:"return false;"},
            {name:"continent93", showIf:"return false;"},
            {name:"continent94", showIf:"return false;"},
            {name:"continent95", showIf:"return false;"},
            {name:"continent96", showIf:"return false;"},
            {name:"continent97", showIf:"return false;"},
            {name:"continent98", showIf:"return false;"},
            {name:"continent99", showIf:"return false;"},
            {name:"continent100", showIf:"return false;"},
            {name:"continent101", showIf:"return false;"},
            {name:"continent102", showIf:"return false;"},
            {name:"continent103", showIf:"return false;"},
            {name:"continent104", showIf:"return false;"},
            {name:"continent105", showIf:"return false;"},
            {name:"continent106", showIf:"return false;"},
            {name:"continent107", showIf:"return false;"},
            {name:"continent108", showIf:"return false;"},
            {name:"continent109", showIf:"return false;"},
            {name:"continent110", showIf:"return false;"},
            {name:"continent111", showIf:"return false;"},
            {name:"continent112", showIf:"return false;"},
            {name:"continent113", showIf:"return false;"},
            {name:"continent114", showIf:"return false;"},
            {name:"continent115", showIf:"return false;"},
            {name:"continent116", showIf:"return false;"},
            {name:"continent117", showIf:"return false;"},
            {name:"continent118", showIf:"return false;"},
            {name:"continent119", showIf:"return false;"},
            {name:"continent120", showIf:"return false;"},
            {name:"continent121", showIf:"return false;"},
            {name:"continent122", showIf:"return false;"},
            {name:"continent123", showIf:"return false;"},
            {name:"continent124", showIf:"return false;"},
            {name:"continent125", showIf:"return false;"},
            {name:"continent126", showIf:"return false;"},
            {name:"continent127", showIf:"return false;"},
            {name:"continent128", showIf:"return false;"},
            {name:"continent129", showIf:"return false;"},
            {name:"continent130", showIf:"return false;"},
            {name:"continent131", showIf:"return false;"},
            {name:"continent132", showIf:"return false;"},
            {name:"continent133", showIf:"return false;"},
            {name:"continent134", showIf:"return false;"},
            {name:"continent135", showIf:"return false;"},
            {name:"continent136", showIf:"return false;"},
            {name:"continent137", showIf:"return false;"},
            {name:"continent138", showIf:"return false;"},
            {name:"continent139", showIf:"return false;"},
            {name:"continent140", showIf:"return false;"},
            {name:"continent141", showIf:"return false;"},
            {name:"continent142", showIf:"return false;"},
            {name:"continent143", showIf:"return false;"},
            {name:"continent144", showIf:"return false;"},
            {name:"continent145", showIf:"return false;"},
            {name:"continent146", showIf:"return false;"},
            {name:"continent147", showIf:"return false;"},
            {name:"continent148", showIf:"return false;"},
            {name:"continent149", showIf:"return false;"},
            {name:"continent150", showIf:"return false;"},
            {name:"continent151", showIf:"return false;"},
            {name:"continent152", showIf:"return false;"},
            {name:"continent153", showIf:"return false;"},
            {name:"continent154", showIf:"return false;"},
            {name:"continent155", showIf:"return false;"},
            {name:"continent156", showIf:"return false;"},
            {name:"continent157", showIf:"return false;"},
            {name:"continent158", showIf:"return false;"},
            {name:"continent159", showIf:"return false;"}
    
    	];
    
    
    	var l=animalsGridFields.length;
    	for (var k=0; k<l; k++){
    		var field = animalsGridFields[k];
    		field = setSummaryFunctions(field,animalsGrid);
    
    	}
    
    
    
        animalsGrid.setFields(animalsGridFields);
       
    
    }
    
    
    function setSummaryFunctions(field,grid){
    	
    	if( field.showGridSummary){
    		
    
    	}else{
    		
    		//isc.Log.logInfo("setting noSummaryFunctions for " + field.name);
    		//add function to display labels in left most column
    		field.showGridSummary=true;
    		field.showGroupSummary=true;
    		field.summaryFunction=grid.noSummaryFunctions;
    			
    	}
    	
    	return field;
    }
    
    
    function getGridNoSummaryFunctions(){
    	
    	var noSummaryFunctions=[];
    
      
    	var totalNoSummaryFunction="return null;";
    	noSummaryFunctions.push(totalNoSummaryFunction);
    	
    	return	noSummaryFunctions;
    }
    
    function updateQuickAddGrid(){
    
    		quickAddGrid.cancelEditing();
    		quickAddGrid.discardAllEdits();
    		quickAddGrid.markForRedraw();
    
    	    var animalResultSet = isc.ResultSet.create({
    	   		dataSource: animals,
    			initialData: [],
    			criteria: {}
    		});
    		
    		quickAddGrid.setData(animalResultSet); 
    
        quickAddGrid.setFields([
    		{name:"scientificName",required:true},
    		{name:"commonName"},
    		{name:"lifeSpan"},
    	     {name:"status"}
    	]
       )
    
    }
    
      function stripTags(str) {
    	 
    	 
    	if(str!=null && isA.Function(str.split)){
    		//add logic to preserve <br> by converting to \n charcters and then back
    		str=str.replaceAll("<br/>","\n");
    		str=str.replaceAll("&lt;br&gt;", "\n");
    		
    		//convert other representations of open and close tag
    		//to their text equivalents first
    		str=str.replaceAll("&lt;","<");
    		str.replaceAll("&gt;",">");
    		str=str.replaceAll("&#60;","<");
    		str.replaceAll("&#62;",">");
    		str=str.replaceAll("&lt","<");
    		str.replaceAll("&gt",">");
    		str=str.replaceAll("&#60","<");
    		str.replaceAll("&#62",">");
    
    		
    	}
    	
    
    
    	if(str!=null && isA.Function(str.replace)){
    
    		var returnString = str.replace(/<\/?[^>]+>/gi, '');			
    
    		//comment out logic that preserves breaks until iso fixed fixedRecordHeight issue with Firefox
    		//returnString = returnString.replaceAll("\n","<br/>");
    		return returnString;
      	}else{
      		return str;
      	}
      	
      }
    
    function stripDSFields(data,dsFields,deleteNullFields,deleteDisplayOnly, keepExportFieldsOnly){
    
    	//remove any Datasource fields from data object for DSRequest --%>
    	var keys = isc.getKeys(data);
    	var j = keys.length;
    	for (var i = 0; i < j; i++){
    
    		var key = keys[i];
    		var dsField = dsFields[key];
    		
    		//strip out html tags so they don't get into db
    		if(dsField!=null && dsField.type!=null &&  ( dsField.type.toLowerCase()=="text")){
    			var value = isc.getValueForKey(key,data);
    			if(value!=null && value!=key){
    				value = stripTags(value,true);
    				data[key]=value;
    			}
    		}
    		
    
    		
    		//if we are keeping export fields and this is one, continue without removing
    		if(keepExportFieldsOnly){
    			if(dsField!=null && dsField.exportField){
    				continue;
    			}else{
    				delete data[key];
    			}
    		}
    		
    		//delete all fields that are not defined as datasource fields 
    		if((deleteNullFields==null || deleteNullFields) && dsField==null){
    			delete data[key];
    			continue;
    		}
    		
    		//remove any client-side or display only
    		//attributes and any fields that are part of another datasource--%>
    		if(dsField!=null && (isc.DataSource.getDataSource(dsField.type)!=null || ((deleteDisplayOnly==null || deleteDisplayOnly) && dsField.displayOnly))){
    			delete data[key];
    		}
    	}
    	
    	return data;
    	
    
    }
    
    
    function initPageLayout(){
    
        updateAnimalGamesSave()
        updateAnimalGamesSummary();
        updateAnimalGamesEditor();
        updateAnimalDataEditor();
        updateFindAnimalsForm()
        updateAnimalsGrid();
    
      
       pageLayout.draw();
    
       //rightSections.showSection(0); 
       rightSections.showSection(1);
       rightSections.showSection(2);
       rightSections.hideSection(3);
       
       rightSections.collapseSection(2);
    
    	at.initialLayoutComplete=true;
    
       //isc.Timer.setTimeout("animalsGrid.groupBy('information');",4000);
    
    }
    
    
    function initialDataLoad(data,dsRequest){
    
    	createAnimalResultSet(data,dsRequest,data,true);
    
    	initPageLayout();
    }
    
    
    function createAnimalResultSet(data,dsRequest,data,initialLoad){
    
    
    	var j = data.length;
    	for (var i = 0; i < j; i++){
    		var record = data[i];
    		record.lifeSpan2 = record.lifeSpan*2;
    	}
    
    	  var animalResultSet = isc.ResultSet.create({
       		dataSource: animals,
    		initialData: data,
    		criteria: dsRequest.data
    		,neverDropUpdatedRows:true
    		});
    	
    
    	animalsGrid.setData(animalResultSet);
    
    }
    
    animals.fetchData({status:"Threatened",lifeSpan:10},"initialDataLoad(data,dsRequest);");
    
    
     function formatNumber (record,anynum, decimal,label,labelPosition,adjustDecimal, divideBy) {
    
    	
    	 if(anynum == null || !isNumber(anynum)){
    		 
    		 	//4/28/11.try to convert to number before failing
    		 	 anynum = Number(anynum);
    		 	 if(!isNumber(anynum)){
    				 return "NA";		 		 
    		 	 }
    	 }
    
    	   if(divideBy!=null){
    		   anynum = anynum/divideBy;
    	   }
    	 
    	   var divider =10;
    	   switch(decimal){
    			case 0:
    				divider =1;
    				break;
    			case 1:
    				divider =10;
    				break;
    			case 2:
    				divider =100;
    				break;
    			case 3:
    				divider =1000;
    				break;
    			case 4:
    				divider =10000;
    				break;
    			case 5:
    				divider =100000;
    				break;
    			case 6:
    				divider =1000000;
    				break;
    			case 7:
    				divider =10000000;
    				break;
    			case 8:
    				divider =100000000;
    				break;
    			default:  	 //for 3 decimal places--%>
    				divider =1000;
    		}
    
    	   var workNum=Math.abs((Math.round(anynum*divider)/divider));
    
    
    	   
    	   var workStr=""+workNum
    
    	   if (workStr.indexOf(".")==-1){workStr+="."}
    
    	   var dStr=workStr.substr(0,workStr.indexOf("."));
    	   var dNum=dStr-0;
    	   var pStr=workStr.substr(workStr.indexOf("."));
    
           //only fix the decimals if the adjustDecimal param is set to false--%>
            if(adjustDecimal!=null && !adjustDecimal){
    		   while (pStr.length-1< decimal){pStr+="0"}
    		}
    
    	   if(pStr =='.') pStr ='';
    
    	   // Adds a comma in the thousands place.--%>	    
    	   if (dNum>=1000) {
    		  var dLen=dStr.length
    		  dStr=parseInt(""+(dNum/1000))+","+dStr.substring(dLen-3,dLen)
    	   }
    
    	   // Adds a comma in the millions place.--%>	   
    	   if (dNum>=1000000) {
    		  dLen=dStr.length
    		  dStr=parseInt(""+(dNum/1000000))+","+dStr.substring(dLen-7,dLen)
    	   }
    
    	   // Adds a comma in the billions place--%>
    	   if (dNum>=1000000000) {
    		  dLen=dStr.length
    		  dStr=parseInt(""+(dNum/1000000000))+","+dStr.substring(dLen-11,dLen)
    	   }
    
    	   // Adds a comma in the trillions place.--%>
    	   if (dNum>=1000000000000) {
    		  dLen=dStr.length
    		  dStr=parseInt(""+(dNum/1000000000000))+","+dStr.substring(dLen-15,dLen)
    	   }
    
    	   if (dNum>=1000000000000000) {
    		  dLen=dStr.length
    		  dStr=parseInt(""+(dNum/1000000000000000))+","+dStr.substring(dLen-19,dLen)
    	   }
    
    	   if (dNum>=1000000000000000000) {
    		  dLen=dStr.length
    		  dStr=parseInt(""+(dNum/1000000000000000000))+","+dStr.substring(dLen-23,dLen)
    	   }
    
    	   if (dNum>=1000000000000000000000) {
    		  dLen=dStr.length
    		  dStr=parseInt(""+(dNum/1000000000000000000000))+","+dStr.substring(dLen-27,dLen)
    	   }
    	   	   	   	   
    	   var retval = dStr + pStr
    	   
    	if(labelPosition != null && label != null && label!=""){
    		if(labelPosition == "before"){
    			  retval = label + retval;
    		} else {
    			  retval = retval + "&nbsp;" + label;
    		}
    	}
    	
    	// Put numbers in parentheses if negative.--%>
    	if (anynum<0) {
    		retval="("+retval+")";
    	}
    
    	return retval;
     }
    
    function isNumber(value) {
    
    
        return typeof value === 'number' && isFinite(value);	
    }
    
    
    
    function formatString(record,value){
    	
    		if(record==null || value == null){
    			if(record!=null && record.isGroupSummary!=null && record.isGroupSummary){
    				return null;
    			}else{
    				 return "NA";			
    			}
    		}
    		var returnValue = new String();
    	
    		if(value !=null){
    			returnValue += value;
    		}	
    		
    
    		
    		
    		return returnValue;
    	
    }
    
    </SCRIPT>
    </BODY></HTML>

    #2
    It looks like you're referring to this logic in "formatString":
    Code:
    		if(record==null || value == null){
    			if(record!=null && record.isGroupSummary!=null && record.isGroupSummary){
    				return null;
    			}else{
    				 return "NA";			
    			}
    		}
    - Right?
    If so you're checking for record.isGroupSummary which is the property set on group-summary rows -- not for record.isGridSummary which is set on grid summary rows.

    If you modify the check to test for record.isGridSummary it successfully avoids returning "NA".

    This was presumably working in 8.2 simply because the formatter wasn't being applied to the grid-summary row at all for this field.

    Comment


      #3
      Thanks, makes sense. I wasn't checking for isGridSummary because it wasn't needed in 8.2. I've made the needed adjustments.

      Comment

      Working...
      X