Showing posts with label write. Show all posts
Showing posts with label write. Show all posts

Wednesday, March 28, 2012

Extending the AutoComplete extender

I am trying to add more to the functionality of the AutoComplete extender. I would like to write my own and inherit from AutoCompleteExtender.

I would like to add a member variable that will hold the results from the last search ( similar to what the cache does, but just for the last search ) and then at a later point be able to compare a given string a see if it is one of the strings returned from the last search.

I am having trouble with the js. Any help would be appreciated

here is what my js file looks like, but I am not sure how to save the results from the last search.

Type.registerNamespace('CustomAutoCompleteControl');

CustomAutoCompleteControl.CustomAutoCompleteControlBehavior = function(element) {
CustomAutoCompleteControl.CustomAutoCompleteControlBehavior.initializeBase(this, [element]);
}

CustomAutoCompleteControl.CustomAutoCompleteControlBehavior.prototype = {

this._suggestions: null,

clearSuggestions: function() {
this._suggestions = null;
}
}

CustomAutoCompleteControl.CustomAutoCompleteControlBehavior.registerClass('CustomAutoCompleteControl.CustomAutoCompleteControlBehavior', Sys.Preview.UI.AutoCompleteBehavior);


I also created the .cs class and added the ClientScriptResource entry to make reference to the js file.

Do I need to overwrite the _update function, or what should I do to save the results? Any code would be helpful.

Thanks in advance

Looking at the AutoCompleteExtender, the completion list handles the mouseDown and Enter/Tab keypress events and calls a function by the name of setText which sets the textbox.

You may be able to use the existing property _currentPrefix...


_setText: function(text) {
this._timer.set_enabled(false);
this._currentPrefix = text;
var element = this.get_element();
var control = element.control;
// todo: should check for 'derives from' too and should somehow manually cause TB to raise property changed event
if (control && control.set_text) {
control.set_text(text);
}
else {
element.value = text;
}
this._hideCompletionList();
},


I would like to save the suggestions right before they are displayed to the user. There is a method called _update that is called which I think I would need to override, but I am not sure what the correct syntax to overriding a method is with this framework. Do I just rewrite that method the way I want it in my class and it will know to use that version for that method and the parent class' methods for the others? Do I need to override any other methods in order to make it work.

I think I have an idea on what I need to do, but the syntax is holding me back here. Any suggestions are appreciated.


Sorry, I misunderstood the first post. I thought you wanted to save the last finalized choice.

Monday, March 26, 2012

Expand/Collapse a group of CollapsiblePanelExtenders

I have a page with a group of CollapsiblePanelExtender controls I want to write a javascript function to expand or collapse all panels together at the same time. Is this possible and please how?

Thanks in advance

You can put your group of CollapsiblePanelExtender inside adiv/paneland have the collapse/expand controlid use thediv/panel.Its like a nested CollapsiblePanelExtender .


Hi Jessy ,

I have convered the EXACT SAME scenario on my blog over as an example of :

How to : Perform Operations on all instances of a Ajax Control Extender on a page

Hope this helps


Thanks Phanatic this is exactly what I need