Wednesday, March 21, 2012

A Question about Atlas client control Inheritance from Sys.UI.Select

Type.registerNamespace('Sys.UI');
Sys.UI.spxSelect = function(associatedElement) {
Sys.UI.spxSelect.initializeBase(this, [associatedElement]);
var _OnSelChange;
this.onSelChanged=this.createEvent();
this.get_selectedText = function() {
return this.element.options(this.element.selectedIndex).text;
}
this.dispose = function() {
Sys.UI.spxSelect.callBaseMethod(this, 'dispose');
}

this.getDescriptor = function() {
var td = Sys.UI.spxSelect.callBaseMethod(this, 'getDescriptor');
td.addProperty('selectedText', String,true);
return td;
}
Sys.UI.spxSelect.registerBaseMethod(this, 'getDescriptor');

this.initialize = function() {
Sys.UI.spxSelect.callBaseMethod(this, 'initialize');
_OnSelChange = Function.createDelegate(this, this.onSelChanged);
this.selectionChanged.add(_OnSelChange);

}
this.onSelChanged = function() {
this.raisePropertyChanged('selectedText');
}

}
Sys.UI.spxSelect.registerClass('Sys.UI.spxSelect', Sys.UI.Select);
Sys.TypeDescriptor.addType('script', 'spxselect', Sys.UI.spxSelect);

Why

this.onSelChanged = function() {
this.raisePropertyChanged('selectedText');
}

can't run after raise selectionChanged

Hi,

you have declared onSelChanged to be both an event:

this.onSelChanged=this.createEvent();

and a function:

this.onSelChanged = function() {

I think that removing the event declaration should fix it.


I fix it ,but it's have the same question


I have also found that if you inherit from an Atlas control, for example, Sys.UI.Button, and implement the initialize() method, the initialize() method of Sys.UI.Button does NOT get invoked because the initialize() method of Sys.UI.Button isn't registered as a BaseMethod. My question is: why not? Can anyone from the Atlas team please explain.

tzkuei


in yuor this.getDescriptor = function() {}

add line

td.addEvent('onSelChanged', true);

to register the event


Xiyuan Shen:

in yuor this.getDescriptor = function() {}

add line

td.addEvent('onSelChanged', true);

to register the event

Sys.UI.Select:

this._onSelectionChanged = function() {
this.raisePropertyChanged('selectedValue');
this.selectionChanged.invoke(this, Sys.EventArgs.Empty);
}

My Select:

var _OnSelChange;

this.initialize = function() {
Sys.UI.spxSelect.callBaseMethod(this, 'initialize');
_OnSelChange = Function.createDelegate(this, this.onSelChanged);
this.selectionChanged.add(_OnSelChange);

}
this.onSelChanged = function() {
this.raisePropertyChanged('selectedText');
}

Sorry,My question is how I can captureSelect.selectionChanged event in my select controlonSelChanged


The initialize() method of Sys.UI.Select is NOT invoked by Sys.UI.spxSelect.callBaseMethod(this, 'initialize'); therefore the onchange event is not hooked up.

I have raised this point in my post here: http://forums.asp.net/thread/1250969.aspx


if inseted line in my previous post to you getDescriptor function, then the syntax for the markup sholud look like this

<spxselect id="XXX"onSelChanged="youreventhandlerhere" ...>

</spxselect>

please notice that the name of prpoerty (red highlighted) is defiend by the line i posted for you.

No comments:

Post a Comment