Announcement

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

  • custom listgrid

    This is quite urgent - would be great if someone could respond right away.

    I have a custom canvas item that I have created using ListGrid- I am trying to set its value by calling setValue() and inside my overwrite of this function, I call setData() - Unfortunately, it is not working. I tried the same thing with a simple listgrid and it works fine - am I missing something?


    Code:
    <HTML><HEAD><TITLE>Test Show All</TITLE>
        <SCRIPT>var isomorphicDir = "isomorphic/"</SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Core.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Foundation.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Containers.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Grids.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Forms.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_DataBinding.js></SCRIPT>
    	<SCRIPT SRC=isomorphic/skins/Enterprise/load_skin.js></SCRIPT>
    </HEAD><BODY CLASS="pageBackground">
    
    <SCRIPT>
    isc.ClassFactory.defineClass("CwAdvancedSelectItem", "CanvasItem");
    
    isc.CwAdvancedSelectItem.addProperties({
        init:function () {
    		var suppressTab = this.tabIndex == -1;
    		this.selectedList = isc.ListGrid.create({
    			ID: this.ID+"$cwSelList",
    			width: this.width,
    			height: this.height,
    			showHeader:false,
    			showAllRecords:true,
    			data: countryData,
    			fields:[        {name:"countryName", title:"Country",showTitle:false}]
    		}),
    		this.fullList = isc.ListGrid.create({
    			ID: this.ID+"$cwSelList",
    			width: 200,
    			height: 224,
    			fields:[{name:"$cwCodeDesc", showTitle:false}],
    			hidden:true,
    		}),
    		this.saveButton = isc.Button.create({
    			ID:this.ID+"$cwSave",autoDraw:false,
    			title: "Save", //make a resorce
    			hidden:true,
    			click: function(){
    				this.selectedList.setData(this.fullList.getSelectedRecords());
    			}
    		}),
    		this.cancelButton = isc.Button.create({
    			ID: this.ID+"$cwCancel",autoDraw:false,
    			hidden:true,
    			title: "Cancel", //make a resource
    			click:function(){
    			//close the popup
    			}
    		}),
    		this.setDisabled = function(disabled){
    			this.expandButton.hide();
    		},
    		this.expandButton = isc.Button.create({
    			ID: this.ID+"$cwExpand",
    			title: "...",
    			width:25,
    			height:25,
    			left: 300,
    			top: 200,
    			click:function(){
    				//show popup
    			}
    		}),
            this.canvas = 
    	       isc.HStack.create({
    				ID: this.ID,
    				width:this.width + 200,
    				height: this.height + 200,
    				members:[
    				this.selectedList,this.expandButton
    				]
    		}),
    		this.getValue = function(){
    			var selected = this.selectedList.data;
    			
    			if(selected!=null){
    				var selNum = this.selectedList.getLength();
    				var selIds;
    				for(var i=0; i < selNum;i++){
    					if(i > 0){
    						selIds += "," + this.selectedList.get(i).id;
    					}else{
    						selIds = this.selectedList.get(i).id;
    					}
    				}
    				return selIds;
    			}
    		},
    		
    		this.setValue = function(newValue){
    			this.selectedList.setData(newValue);
    		}
    		   
            return this.Super("init", arguments);
        }
    });
    
    var countryData = [
    
    {
        continent:"North America",
        countryName:"United States",
        countryCode:"US",
        area:9631420,
        population:298444215,
        gdp:12360.0,
        independence:new Date(1776,6,4),
        government:"federal republic",
        government_desc:2,
        capital:"Washington, DC",
        member_g8:true,
        article:"http://en.wikipedia.org/wiki/United_states"
    },
    {
        continent:"Asia",
        countryName:"China",
        countryCode:"CH",
        area:9596960,
        population:1313973713,
        gdp:8859.0,
        government:"Communist state",
        government_desc:0,
        capital:"Beijing",
        member_g8:false,
        article:"http://en.wikipedia.org/wiki/China"
    },
    {
        continent:"Asia",
        countryName:"Japan",
        countryCode:"JA",
        area:377835,
        population:127463611,
        gdp:4018.0,
        government:"constitutional monarchy with parliamentary government",
        government_desc:1,
        capital:"Tokyo",
        member_g8:true,
        article:"http://en.wikipedia.org/wiki/Japan"
    },
    {
        continent:"Asia",
        countryName:"India",
        countryCode:"IN",
        area:3287590,
        population:1095351995,
        gdp:3611.0,
        independence:new Date(1947,7,15),
        government:"federal republic",
        government_desc:2,
        capital:"New Delhi",
        member_g8:false,
        article:"http://en.wikipedia.org/wiki/India"
    }];
    
    
    isc.DynamicForm.create({
    ID:"newUI",
    fields:[{_constructor: "CwAdvancedSelectItem", width:200, height:200, ID:"testAdvanced"}]
    });
    
    isc.ListGrid.create({
        ID: "countryList",
        width:200, height:224, alternateRecordStyles:true,left:400,top:400,
        selectionAppearance:"checkbox",
        fields:[
            {name:"countryName", title:"Country",showTitle:false}
        ],
        selectionChanged: "selectedCountries.setData(this.getSelection())"
    })
    
    testAdvanced.setValue(countryData);
    countryList.setData(countryData);
    
    
    </SCRIPT>
    </BODY>
    </HTML>

  • #2
    Just realized I have hard-coded stuff in the previous sample:

    I also changed my call to setValue to setGenValue because when I debugged through it, setValue goes and calls some other function and nullifies the parameter I've sent before it gets to my setValue implementation.

    Code:
    <HTML><HEAD><TITLE>Test Show All</TITLE>
        <SCRIPT>var isomorphicDir = "isomorphic/"</SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Core.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Foundation.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Containers.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Grids.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Forms.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_DataBinding.js></SCRIPT>
    	<SCRIPT SRC=isomorphic/skins/Enterprise/load_skin.js></SCRIPT>
    </HEAD><BODY CLASS="pageBackground">
    
    <SCRIPT>
    isc.ClassFactory.defineClass("CwAdvancedSelectItem", "CanvasItem");
    
    isc.CwAdvancedSelectItem.addProperties({
        init:function () {
    		var suppressTab = this.tabIndex == -1;
    		this.selectedList = isc.ListGrid.create({
    			ID: this.ID+"$cwSelList",
    			width: this.width,
    			height: this.height,
    			showHeader:false,
    			showAllRecords:true,
    			fields:[        {name:"countryName", title:"Country",showTitle:false}]
    		}),
    		this.fullList = isc.ListGrid.create({
    			ID: this.ID+"$cwSelList",
    			width: 200,
    			height: 224,
    			fields:[{name:"$cwCodeDesc", showTitle:false}],
    			hidden:true,
    		}),
    		this.saveButton = isc.Button.create({
    			ID:this.ID+"$cwSave",autoDraw:false,
    			title: "Save", //make a resorce
    			hidden:true,
    			click: function(){
    				this.selectedList.setData(this.fullList.getSelectedRecords());
    			}
    		}),
    		this.cancelButton = isc.Button.create({
    			ID: this.ID+"$cwCancel",autoDraw:false,
    			hidden:true,
    			title: "Cancel", //make a resource
    			click:function(){
    			//close the popup
    			}
    		}),
    		this.setDisabled = function(disabled){
    			this.expandButton.hide();
    		},
    		this.expandButton = isc.Button.create({
    			ID: this.ID+"$cwExpand",
    			title: "...",
    			width:25,
    			height:25,
    			left: 300,
    			top: 200,
    			click:function(){
    				//show popup
    			}
    		}),
            this.canvas = 
    	       isc.HStack.create({
    				ID: this.ID,
    				width:this.width + 200,
    				height: this.height + 200,
    				members:[
    				this.selectedList,this.expandButton
    				]
    		}),
    		this.getValue = function(){
    			var selected = this.selectedList.data;
    			
    			if(selected!=null){
    				var selNum = selected.getLength();
    				var selIds;
    				for(var i=0; i < selNum;i++){
    					if(i > 0){
    						selIds += "," + selected.get(i).countryCode;
    					}else{
    						selIds = selected.get(i).countryCode;
    					}
    				}
    				return selIds;
    			}
    		},
    		
    		this.setGenValue = function(newValue){
    			this.selectedList.data = newValue;
    		}
    		   
            return this.Super("init", arguments);
        }
    });
    
    var countryData = [
    
    {
        continent:"North America",
        countryName:"United States",
        countryCode:"US",
        area:9631420,
        population:298444215,
        gdp:12360.0,
        independence:new Date(1776,6,4),
        government:"federal republic",
        government_desc:2,
        capital:"Washington, DC",
        member_g8:true,
        article:"http://en.wikipedia.org/wiki/United_states"
    },
    {
        continent:"Asia",
        countryName:"China",
        countryCode:"CH",
        area:9596960,
        population:1313973713,
        gdp:8859.0,
        government:"Communist state",
        government_desc:0,
        capital:"Beijing",
        member_g8:false,
        article:"http://en.wikipedia.org/wiki/China"
    },
    {
        continent:"Asia",
        countryName:"Japan",
        countryCode:"JA",
        area:377835,
        population:127463611,
        gdp:4018.0,
        government:"constitutional monarchy with parliamentary government",
        government_desc:1,
        capital:"Tokyo",
        member_g8:true,
        article:"http://en.wikipedia.org/wiki/Japan"
    },
    {
        continent:"Asia",
        countryName:"India",
        countryCode:"IN",
        area:3287590,
        population:1095351995,
        gdp:3611.0,
        independence:new Date(1947,7,15),
        government:"federal republic",
        government_desc:2,
        capital:"New Delhi",
        member_g8:false,
        article:"http://en.wikipedia.org/wiki/India"
    }];
    
    
    isc.DynamicForm.create({
    ID:"newUI",
    fields:[{_constructor: "CwAdvancedSelectItem", width:200, height:200, ID:"testAdvanced"}]
    });
    
    isc.ListGrid.create({
        ID: "countryList",
        width:200, height:224, alternateRecordStyles:true,left:400,top:200,
        selectionAppearance:"checkbox",
        fields:[
            {name:"countryName", title:"Country",showTitle:false}
        ],
        selectionChanged: "selectedCountries.setData(this.getSelection())"
    })
    
    testAdvanced.setGenValue(countryData);
    countryList.setData(countryData);
    
    
    </SCRIPT>
    </BODY>
    </HTML>

    Comment


    • #3
      If it wasn't clear in my last post, even with calling my setGenValue, I am still not seeing the data I want (sorry for the multiple posts)!

      Comment


      • #4
        I guess my sense of urgency wasn't enough - could someone please get back to me as soon as possible? I need to get this working by today.

        Comment


        • #5
          I've figured out the issue - please delete this thread.

          Comment

          Working...
          X