This is a migrated thread and some comments may be shown as answers.

"Serial" Spell checking?

4 Answers 107 Views
Spell
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 30 Jan 2009, 06:01 PM
I am new to the Telerik controls and am trying to do something specific using Spell. I want to have multiple controls on a page that are checked for spelling errors (which is easy enough), but I would like for them to be checked individually and in sequence. In other words, check Control 1, do all fixes, then move on to Control 2, etc. without displaying the results from one control in another's dialog box.

I have been trying to use code like the following to achieve this:

var spell = $find("RadSpell1");   
for (var i=0; i < 2; i++) 
    spell.spellCheck(elements[i]); 
where elements contains the array of controls, or

spell.spellCheck(elementOne); 
spell.spellCheck(elementTwo); 

Each time, the spell check seems to somehow ignore the first control and focus on the second control. I can check both controls as normal or each one individually (without the other), so they appear to be set up correctly. I just cannot check one and then the other. Is this even possible? Am I missing something obvious here?

Thanks for any insight,
Scott


4 Answers, 1 is accepted

Sort by
0
Tervel
Telerik team
answered on 02 Feb 2009, 03:41 PM
Hi Scott,

The problem comes from the fact that javascript code cannot block the browser execution thread.
Hence, after the first spellCheck call, the second call is immediately execute - scrapping any previous request.

To implement your scenario you can, for example, hook to RadSpell client-side event spell check for the next control, etc.

More information on client-side events can be found in  the following online demo:
http://demos.telerik.com/aspnet-ajax/spell/examples/clientsideevents/defaultcs.aspx

All the best,
Tervel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Scott
Top achievements
Rank 1
answered on 13 Feb 2009, 04:39 PM
Thank you for your reply. I have looked into trying what you suggested, but I am still having problems. Do you have any further guidance, pseudo-code, or actual code examples?

Here is what I have tried (partial code listing follows). I created an array of the control names that I wanted checked. My idea is to iterate through the array and explicitly tell RadSpell to check each element. With the code below, this is what I see:

1. Put values into screen elements and click Spell Check button
2. Spell check starts for first screen element in array and works as expected.
3. Click Change to accept suggestion, and spellCheckFinished() launches as expected.
4. Script gets set to check the next field in the array.
5. Starts spell check (i.e., calls spellCheck()) for second field as expected.
6. Instead of populating the spell check dialog with the second field, the results of the first check remain, and I see the default "The Spell Check is complete!" message.

It seems like the spell checker is locked into its completed state and will not come out. I have tried to manually call SetSpellChecked(), but that doesn't do anything (literally, the JavaScript appears to stop running - is it deprecated or do I need to install something?)

Thanks for any ideas on this,
Scott

ASP code:
<telerik:RadSpell ID="RadSpell1" runat="Server" OnClientCheckFinished="spellCheckFinished" 
        WordIgnoreOptions="WordsWithNumbers" ButtonType="None" 
        IsClientID="True" SupportedLanguages="en-US,English"/>   
<br /><br />  
<input type="button" onclick="spellCheck()" value="Spell Check" /> 
 

Javascript:
function spellCheck() 
    alert("starting spell check for:"+listArray[fieldCounter]); 
    var spell = $find("RadSpell1"); 
 
    // prepare field 
    var element = new Telerik.Web.UI.Spell.HtmlElementTextSource($get(listArray[fieldCounter])); 
         
    spell.spellCheck(element); 
 
function spellCheckFinished(sender, args) 
    alert("check finished"); 
         
    // If array is not done, increment. Otherwise, reset counter 
    if ( fieldCounter < (listArray.length - 1) ) 
    { 
        fieldCounter++; 
        alert("check the next field"); 
        args.SuppressCompleteMessage = true
             
        spellCheck(); 
    } 
    else 
    { 
        alert("done with all fields"); 
        fieldCounter = 0; 
    } 
 

0
Accepted
Tervel
Telerik team
answered on 16 Feb 2009, 03:14 PM
Hello Scott,

I played with the code provided from you. Attached is a tweaked version with a couple of minor changes here and there.

Best regards,
Tervel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Scott
Top achievements
Rank 1
answered on 17 Feb 2009, 02:38 PM
This appears to work. Thanks for your efforts in getting me on the right path.

Scott
Tags
Spell
Asked by
Scott
Top achievements
Rank 1
Answers by
Tervel
Telerik team
Scott
Top achievements
Rank 1
Share this question
or