Go Back   SmartClient Forums > Technical Q&A
Wiki Register Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 13th Apr 2012, 14:29
acarur01 acarur01 is offline
Registered Developer
 
Join Date: Dec 2008
Posts: 1,413
Default 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>
Reply With Quote
  #2  
Old 13th Apr 2012, 14:51
acarur01 acarur01 is offline
Registered Developer
 
Join Date: Dec 2008
Posts: 1,413
Default

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>
Reply With Quote
  #3  
Old 13th Apr 2012, 14:56
acarur01 acarur01 is offline
Registered Developer
 
Join Date: Dec 2008
Posts: 1,413
Default

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)!
Reply With Quote
  #4  
Old 16th Apr 2012, 05:20
acarur01 acarur01 is offline
Registered Developer
 
Join Date: Dec 2008
Posts: 1,413
Default

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.
Reply With Quote
  #5  
Old 16th Apr 2012, 05:55
acarur01 acarur01 is offline
Registered Developer
 
Join Date: Dec 2008
Posts: 1,413
Default

I've figured out the issue - please delete this thread.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads
Thread Thread Starter Forum Replies Last Post
listgrid with custom widget performance polga Smart GWT Technical Q&A 11 8th Feb 2013 16:02
Custom ListGrid gridComponent Disappearing From View pab Technical Q&A 4 15th Feb 2012 10:32
ListGrid with custom control in cells pgrever Smart GWT Technical Q&A 9 7th Dec 2011 17:17
Custom Data Type in ListGrid vs. SortNormalizer yavery Technical Q&A 2 13th Jul 2011 14:08
Custom DataSourceField in ListGrid ceravolo Smart GWT Technical Q&A 5 25th May 2009 15:43

© 2010,2011 Isomorphic Software. All Rights Reserved