Chase Florell
Top achievements
Rank 1
Chase Florell
asked on 21 Oct 2008, 08:20 PM
Is there an example of how to use the RadSpell in a custom search engine out side of RadEditor?
Basically I want to create a google type search in my content management system that does something like the following.
| My coool search | [search]
did you mean "My cool search"?
1) bla bla bla, my cool search.
http://www.mysite.com/default.aspx?id=3
Basically I want to create a google type search in my content management system that does something like the following.
| My coool search | [search]
did you mean "My cool search"?
1) bla bla bla, my cool search.
http://www.mysite.com/default.aspx?id=3
3 Answers, 1 is accepted
0
Hello,
Unfortunately, there is no easy way to use the RadSpell control without the dialog (e.g. if you want to get the suggestions for a misspelled word). However, you can use the RadEditor control and its ajax spellchecking engine to get suggestions. Here is some sample code:
As you can see, I use a hidden RadEditor control with just the AjaxSpellCheck tool. The checkWord() function initiates an ajax request for the word you wish to check and the response is handled by the spellCallback() function. If the word was not in the spell check dictionary, the suggestions varialbe will hold an array of suggestions you can use in your search dropdown.
All the best,
Lini
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Unfortunately, there is no easy way to use the RadSpell control without the dialog (e.g. if you want to get the suggestions for a misspelled word). However, you can use the RadEditor control and its ajax spellchecking engine to get suggestions. Here is some sample code:
<script type="text/javascript"> |
var spellService = null; |
function checkWord(word) |
{ |
if (!spellService) |
{ |
spellService = $find("<%= spellEditor.ClientID %>").get_spellCheckService(); |
spellService.add_complete(spellCallback); |
} |
spellService.spellCheck(word); |
} |
function spellCallback(sender, args) |
{ |
if (args.badWords.length > 0) |
{ |
var badWord = args.badWords[0]; |
var suggestions = badWord.suggestionsString; |
// suggestions now holds an array of possible spellings for the misspelled word |
} |
} |
</script> |
<input type="button" id="launchButton1" value="Spell Check" onclick="javascript:checkWord('teszt');" /><br /> |
<div style="display:none"> |
<telerik:RadEditor ID="spellEditor" runat="server"> |
<Tools><telerik:EditorToolGroup><telerik:EditorTool Name="ajaxspellcheck" /></telerik:EditorToolGroup></Tools></telerik:RadEditor> |
</div> |
As you can see, I use a hidden RadEditor control with just the AjaxSpellCheck tool. The checkWord() function initiates an ajax request for the word you wish to check and the response is handled by the spellCallback() function. If the word was not in the spell check dictionary, the suggestions varialbe will hold an array of suggestions you can use in your search dropdown.
All the best,
Lini
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Chase Florell
Top achievements
Rank 1
answered on 08 Nov 2008, 12:20 AM
Hmm interesting approach. Is there any way of suggesting this functionality in the future?
0
Hi Chase,
The implementation of the requested feature will work only for editable HTML elements such as the <iframe>. The spellchecker highlights the misspelled word by wrapping it within <span> tags with a class attribute, e.g.
<span id="RadESpellError_2" class="RadEWrongWord">testt</span>
However, this functionality will not work in a textbox or textarea because they could not render the <span> tags and the tags will be displayed inside the content around the misspelled word, which is not an expected behavior.
Nevertheless, I logged your request in our Todo list and our developers will consider its implementation.
Best regards,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
The implementation of the requested feature will work only for editable HTML elements such as the <iframe>. The spellchecker highlights the misspelled word by wrapping it within <span> tags with a class attribute, e.g.
<span id="RadESpellError_2" class="RadEWrongWord">testt</span>
However, this functionality will not work in a textbox or textarea because they could not render the <span> tags and the tags will be displayed inside the content around the misspelled word, which is not an expected behavior.
Nevertheless, I logged your request in our Todo list and our developers will consider its implementation.
Best regards,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.