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

[Solved] Editor in RadGrid

5 Answers 172 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Per Mangseth
Top achievements
Rank 1
Per Mangseth asked on 04 Jun 2008, 01:50 PM
Hi!

I have a RadEditor in an InsertTemplate in a RadGrid. The problem is: If I click a save-button i have in the same template and try to insert the text from the editor to the database, then the grid performs a callback, and all text is removed from the editor.

The same happens if I try to set a text in the editor when I click the button in the grid which opens the InsertTemplate, and also if I  try to save the text from the editor directly to a grid when I save.

It seems that the editor clears all text and settings at each callback. Could it be that it is cleared when I declare it through the following in the ItemCommand of the grid:
RadEditor editTTNewThread = (RadEditor)editFormItem.FindControl("editTTNewThread");

I had the same problems with edit and callback in earlier versions. I tried the same in IE8, and there I manage to set the text programmatically, just after the declaration above, but the same happens when I click the save-button. The editor is cleared.

Edit: In the previous version of the RadControls, I had to use postback instead of callback for it to work, but I really hope that can be avoided.

Another edit: I have now tried the editor in other pages as well, and it seems that every time I use callback on an editor, all the content is cleared.

Any ways to fix this issue?

Cheers,
Erlend Haukland

5 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 09 Jun 2008, 10:11 AM
Hi Per,

Could you please open a support ticket and send us a sample runnable project where the problem can be observed?

Once we are able to reproduce the behavior on our side, we will do our best to provide a solution.


Kind regards,
George
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Per Mangseth
Top achievements
Rank 1
answered on 16 Jun 2008, 02:10 PM
Hi!

Below is the code I am using just to test this

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EditorTest.aspx.cs" Inherits="EditorTest" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="smMaster" runat="server" />
    <div>
        <telerik:RadAjaxPanel runat="server" ID="test">
            <telerik:RadEditor runat="server" ID="editTTNewTT" ToolsFile="Skins/Scorpion/Editor/ToolsFile.xml"
                Skin="Office2007" Width="500" Height="350" EditModes="Design">
            </telerik:RadEditor>
            <br />
            <br />
            <asp:ImageButton runat="server" ID="btnTest" ImageUrl="Img/Buttons/save.png" />
        </telerik:RadAjaxPanel>
    </div>
    </form>
</body>
</html>


I have stripped down my page to a minimum of controls, just the editor and a button. The funny thing is:

If I use an ImageButton to save, the text in the editor is cleared. If I use a regular asp:Button, however, it works just fine. The button does nothing at this point. It just performs a callback. Could you please look into this, and see if you can find any issues with this?

Cheers,
Erlend Haukland
0
Rumen
Telerik team
answered on 16 Jun 2008, 04:39 PM
Hi Erlend,

I am aware that this problem appears in Firefox. Does the problem appear in IE8 beta too?

The solution for the problem is described in the following article: RadEditor Content Not Saved After Ajax Update in Firefox.

When the editor is placed in RadGrid, you can use the following code to fix the problem.

        protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
            GridEditFormItem item = e.Item as GridEditFormItem; //get a reference to the Edit Image button
            if (null != item && item.IsInEditMode)
            {
                ImageButton but = item.FindControl("UpdateButton") as ImageButton;
                but.Attributes.Add("onclick", @"javascript:__doPostBack(this.id,'');");
            }
        }


Please, test the code in both IE and Firefox and let me know if you still experience any problems.

Greetings,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Per Mangseth
Top achievements
Rank 1
answered on 17 Jun 2008, 10:18 AM
Hi!

I've tried this in both IE8 and Firefox now, and it still isn't working. I've use the exact same code as given above in your example, only replacing the gridname with mine.

Cheers,
Erlend Haukland
0
Georgi Tunev
Telerik team
answered on 20 Jun 2008, 11:29 AM
Hello Erlend,

In this case we will need a small sample project which reproduces the problem. Please make sure that the project can be run locally, open a support ticket (you cannot attach files in the forums) and attach it there. We will check it and once we have a better view over your setup, we will get back to you right away.




Kind regards,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Editor
Asked by
Per Mangseth
Top achievements
Rank 1
Answers by
George
Telerik team
Per Mangseth
Top achievements
Rank 1
Rumen
Telerik team
Georgi Tunev
Telerik team
Share this question
or