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

GridHTMLEditorColumn ClientId

9 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peterson
Top achievements
Rank 1
Peterson asked on 02 Jun 2009, 10:42 PM
How do I go about getting the ClientId of the editor generated in a GridHTMLEditorColumn and placing that in a <script> tag? 

I am needing to execute the "set_visible" firefox/ajaxmanager workaround for editors in my grid.  (You can see this problem in action on Telerik's own demo sample:
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/columntypes/defaultcs.aspx
)

There needs to be a ThereIsOnlyOneEditorOnThePageSoAlwaysInitialize property.  ;-)

9 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Jun 2009, 07:58 AM
Hello Tyson,

I am not really clear with your scenario. 0n which client event would you like to pass the ClientId of the Editor? If you want to hide the Editor on clicking the EditButton for some rows then you can do it using server side code as shown below:
c#:
protected void RadGrid1_ItemDataBound (object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem editItem = (GridEditableItem)e.Item; 
            RadEditor editor = (RadEditor)editItem["HTMLEditorColumn"].Controls[0]; 
            editor.Visible = false
           
        } 
     } 

The sample code below shows how to pass the clientId of the Editor on clicking a button on the same row (in EditMode):
aspx:
        <telerik:GridBoundColumn DataField="FirstName" HeaderText="Name" UniqueName="BoundColumn"
        </telerik:GridBoundColumn> 
        <telerik:GridHTMLEditorColumn UniqueName="HTMLEditorColumn" EditFormColumnIndex="0" HeaderText="ID" DataField="ID">         
        </telerik:GridHTMLEditorColumn> 

c#:
  protected void RadGrid1_ItemDataBound (object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem editItem = (GridEditableItem)e.Item; 
            RadEditor editor = (RadEditor)editItem["HTMLEditorColumn"].Controls[0];   
            ((TextBox)editItem["BoundColumn"].Controls[0]).Attributes.Add("onChange""GetEditor('" + editor.ClientID + "');"); 
        } 
     } 

js:
function GetEditor(editor) 
 var editr = document.getElementById(editor); 
 editr.style.display = "none";//to hide the editor 
  

Thanks
Princy.
0
Peterson
Top achievements
Rank 1
answered on 03 Jun 2009, 01:20 PM
Thanks for replying.  I am simply trying to make the editor actually work in edit mode in Firefox when used with RadAjaxManager.  If you click on the demo link I included above, if you will see that in Firefox, the editor simply doesn't work if you try and edit another row.  It's unbelievably frustrating that default functionality doesn't work "out of the box" in a major web browser.

For normal editors, you can fix this by adding the following JS:

<script type="text/javascript">    
    Sys.Application.add_load(function() {    
        var editor = $find("<%=RadEditor1.ClientID%>");    
        editor.set_visible(true);    
        }    
    );    
</script> 

Your examples have given me enough to get going, so thank you.
0
Sebastian
Telerik team
answered on 03 Jun 2009, 01:29 PM
Hello Tyson,

I tested the online demo under FireFox 3.x and the RadEditor worked as expected when editing different grid rows. Let me know if I am missing something or whether you would like to prepare a short video which illustrates what I observed on my machine.

Best regards,
Sebastian
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
Peterson
Top achievements
Rank 1
answered on 06 Jun 2009, 04:10 AM
Interesting.  I had several of my fellow programmers try and the majority *could* edit the grid as described.  However myself and a couple of others could not.  I even tried Firefox (3.0.10) in safe mode, disabling all add-ons.  I will record a screencast and post it, so you can see it in action.  I have not experienced any other ajax anomoly in my browser.  Very strange. 
0
Sebastian
Telerik team
answered on 09 Jun 2009, 09:45 AM
Hello Tyson,

Indeed the issue you depicted is really strange and we have not been contacted with regards to a similar problem before. We will be expecting your video once you are ready with it. Also verify that you are using the latest version 2009.1.527 of RadControls for ASP.NET AJAX in your project.
 
Best regards,
Sebastian
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
Peterson
Top achievements
Rank 1
answered on 12 Jun 2009, 04:18 AM
Sebastian,

You won't believe it, but I found the problem.  To demonstrate, go into your Firefox options, and under the 'Security' tab, uncheck 'Remember passwords for sites' and restart Firefox.  Now try the demo I linked above.  The editor toolbars won't work, and if you edit another row, you won't be able to type in the editor.  Strange, eh?

Hopefully, this can lead you down the path to debug why turning that setting off makes the editor not work in Ajax panels.

Thanks,

Tyson
0
Rumen
Telerik team
answered on 17 Jun 2009, 11:39 AM
Hi Tyson,

The problem is really odd and we will need more time to research what is causing it. The problem could be also reproduced with a standalone editor (not placed in RadGrid item).

As a temporary fix you can use the code below that will switch the editor to HTML and back to Design mode on editor load:

<script type="text/javascript"
function OnClientLoad(editor) 
    if ($telerik.isFirefox) 
    { 
        editor.set_mode(2); 
        editor.set_mode(1); 
    } 
</script> 
<telerik:RadEditor ID="RadEditor1" runat="server" OnClientLoad="OnClientLoad"
    <Modules> 
        <telerik:EditorModule Name="fake" Visible="false" /> 
    </Modules> 
</telerik:RadEditor> 


All the best,
Rumen
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
Peterson
Top achievements
Rank 1
answered on 17 Jun 2009, 08:25 PM
Hey Rumen,

That workaround allows the html area to be edited, but the toolbar is still unresponsive.  I think we'll just remove the AJAX element for now until you guys can fix it.

Thanks for working the issue,

Tyson
0
Peterson
Top achievements
Rank 1
answered on 07 Jul 2009, 01:57 AM
I see the latest build RadEditor fixes this.  Excellent!
Tags
Grid
Asked by
Peterson
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Peterson
Top achievements
Rank 1
Sebastian
Telerik team
Rumen
Telerik team
Share this question
or