Created
July 29, 2017 21:11
-
-
Save A2H111/17d5005241cd779d95d32dde3d96ce94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var finalresult; | |
//Customize the SetText function to create comma separated string from selected values | |
Sys.Extended.UI.AutoCompleteBehavior.prototype._setText = function (item) { | |
var text = (item && item.firstChild) ? item.firstChild.nodeValue : null; | |
this._timer.set_enabled(false); | |
var element = this.get_element(); | |
var control = element.control; | |
//Remove the first value from string which is basically user type for searching | |
if (typeof finalresult === 'undefined') { | |
element.value = ""; | |
} | |
//Split the values | |
finalresult = element.value.trim().split(/,\s*/); | |
//Remove the first comma from string | |
finalresult = cleanArray(finalresult); | |
//Add the current existing value to finalresult variable | |
finalresult.push(text); | |
//Create Comma separated string from selected value | |
finalresult = finalresult.join(","); | |
//Assign the result to textbox control | |
if (control && control.set_text) { | |
control.set_text(finalresult); | |
} else { | |
element.value = finalresult; | |
} | |
$common.tryFireEvent(element, "change"); | |
this.raiseItemSelected(new Sys.Extended.UI.AutoCompleteItemEventArgs(item, text, item ? item._value : null)); | |
this._currentPrefix = this._currentCompletionWord(); | |
this._hideCompletionList(); | |
}; | |
//Here we will Rewrite the _hideCompletionList function to keep the list shown all the time | |
Sys.Extended.UI.AutoCompleteBehavior.prototype._hideCompletionList = function () { | |
var eventArgs = new Sys.CancelEventArgs(); | |
this.raiseHiding(eventArgs); | |
if (eventArgs.get_cancel()) { | |
return; | |
} | |
//The hidePopup function is to close the CompletionList, so we need to | |
// comment this line to ensure the CompletionList is visible. | |
//this.hidePopup(); | |
}; | |
function cleanArray(actual) { | |
var newArray = new Array(); | |
for (var i = 0; i < actual.length; i++) { | |
if (actual[i]) { | |
newArray.push(actual[i]); | |
} | |
} | |
return newArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment