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

RadEditor in RadGrid with batch editing

5 Answers 173 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vincent
Top achievements
Rank 1
Vincent asked on 05 Nov 2013, 01:47 PM
Hello,

I am having a problem with a RadEditor thats in the EditTemplate of a RadGrid that is using the Batch edit mode. All HTML tags are lost after the row loses focus.

Steps to reproduce the issue on the sample below:
1. Click one of the rows to enter edit mode
2. Add a hyperlink using the richtexteditor or make a text bold. Anything that adds one or more HTML tags.
3. Exit edit mode, by clicking a different row.
4. All HTML tags are now lost.

See the code sample below:
Markup:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestCase.aspx.cs" Inherits="Test.TestCase" %>
 
<!DOCTYPE html>
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager runat="server" />
        <telerik:RadGrid ID="gvFactors"
                         runat="server"                         
                         AutoGenerateColumns="false"                           
                         AllowAutomaticInserts="true"
                         AllowAutomaticUpdates="true"   
                         AllowAutomaticDeletes="true" 
                         Skin="Metro"                     
                         OnNeedDataSource="gvFactors_OnNeedDataSource">     
            <MasterTableView TableLayout="Auto" EditMode="Batch" CommandItemDisplay="Top">
                <Columns>
                    <telerik:GridTemplateColumn UniqueName="Text" DataField="Text" ColumnEditorID="tbText">
                        <ItemTemplate>
                            <%# Eval("Text") %>
                        </ItemTemplate>
                        <EditItemTemplate>
                                <telerik:RadEditor ID="tbText"
                                                    runat="server"                         
                                                    Skin="Metro"                                                                                    
                                                    Content='<%#Eval("Text")%>'                                      
                                                    MaxHtmlLength="4000"
                                                    EditModes="Design"/>                                         
                        </EditItemTemplate>                               
                    </telerik:GridTemplateColumn>
                </Columns>               
            </MasterTableView>
        </telerik:RadGrid>      
    </div>
    </form>
</body>
</html>

Code behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace Test {
    public partial class TestCase : System.Web.UI.Page {
        protected void Page_Load(object sender, EventArgs e) {
 
        }
 
        protected void gvFactors_OnNeedDataSource(object sender, EventArgs e) {
            IList<DataItem> items = new List<DataItem>();
            items.Add(new DataItem() { Text = "test1" });
            items.Add(new DataItem() { Text = "test2" });
            items.Add(new DataItem() { Text = "test3" });
 
            this.gvFactors.DataSource = items;
        }
    }
 
    public class DataItem {
        public String Text { get; set; }
    }
}

5 Answers, 1 is accepted

Sort by
0
Vincent
Top achievements
Rank 1
answered on 07 Nov 2013, 08:36 AM
Anyone? I could really use some help on this one...
0
Angel Petrov
Telerik team
answered on 08 Nov 2013, 09:28 AM
Hi Vincent,

I have to say that the behavior experienced is rather expected. The grid in such scenario will escape the HTML tags. Note that allowing the user to insert HTML may expose a security vulnerability and break the editing workflow.

Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Praveen
Top achievements
Rank 1
answered on 01 May 2015, 12:21 PM

When I click radeditor toolbar and select bold in batch edit mode then cell edit mode closed. Please see the screenshots and let me know how to fix it

 

​            

0
Praveen
Top achievements
Rank 1
answered on 01 May 2015, 12:25 PM
attached screenshots
0
Marin Bratanov
Telerik team
answered on 01 May 2015, 12:42 PM

Hello Praveen,

This behavior is expected when the toolbar is not inline inside the editor. Batch edit cells close when the user clicks outside of them by design.

Thus, you need to have the editor with an inline toolbar and you should also employ the approach from the following article so you can work with HTML and not primitive types: http://www.telerik.com/help/aspnet-ajax/grid-batch-editing.html. I am attaching here a small example that you can use as a reference.

Regards,

Marin Bratanov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Grid
Asked by
Vincent
Top achievements
Rank 1
Answers by
Vincent
Top achievements
Rank 1
Angel Petrov
Telerik team
Praveen
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or