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

Grid EditInPlace and GridHTMLEditorColumn

5 Answers 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
tlp
Top achievements
Rank 1
tlp asked on 21 Aug 2011, 02:36 PM
Hello,

I am using version 2011.2.816 of the ASP.NET AJAX grid control and seem to be experiencing some issues with EditInPlace and the GridHTMLEditor column. In particular, when adding or updating a row, the text value obtained from the GridHTMLEditorColumn control is always empty. I noticed that if I removed the grid from the AjaxManager Ajax settings or if I changed the edit command column button type to LinkButton (or PushButton), everything would work fine.

Provided is a sample of the markup and code behind that will reproduce the problem.

<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"></telerik:RadAjaxManager>
        <div>
            <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
        </div>       
    </form>
</body>
</html>




using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
 
using Telerik.Web.UI;
 
public partial class Default3 : System.Web.UI.Page
{
 
    protected RadGrid RadGridNote = null;
 
 
    private int NoteId
    {
        get
        {
            if (ViewState["Id"] == null)
            {
                ViewState["Id"] = 0;
            }
            ViewState["Id"] = (int)ViewState["Id"] + 1;
 
            return (int)ViewState["Id"];
        }      
    }
 
    private List<Note> NotesList
    {
        get
        {
            if (ViewState["NotesList"] == null)
            {
                // Initialize list.
                List<Note> list = new List<Note>();
 
                Note note;
 
                note = new Note();
                note.NoteId = NoteId;
                note.NoteText = "This is the first note.";
                list.Add(note);
 
                note = new Note();
                note.NoteId = NoteId;
                note.NoteText = "This is the seconds note.";
                list.Add(note);
 
                ViewState["NotesList"] = list;
            }
            return (List<Note>)ViewState["NotesList"];
        }
 
        set { ViewState["NotesList"] = value; }
    }
     
 
    override protected void OnInit(EventArgs e)
    {    
        base.OnInit(e);
      
        InitializeGridNote();
    }
 
    protected void Page_Load(object sender, EventArgs e)
    {
        RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadGridNote, RadGridNote);
    }
 
    private void InitializeGridNote()
    {
 
        GridBoundColumn boundColumn;
        GridButtonColumn buttonColumn;
        GridEditCommandColumn editCommandColumn;
        GridHTMLEditorColumn htmlEditorColumn;
 
 
        this.RadGridNote = new RadGrid();
 
        // Set required event handlers.
        RadGridNote.NeedDataSource += new GridNeedDataSourceEventHandler(RadGridNote_NeedDataSource);
        RadGridNote.InsertCommand += new GridCommandEventHandler(RadGridNote_InsertCommand);
        RadGridNote.UpdateCommand += new GridCommandEventHandler(RadGridNote_UpdateCommand);
        RadGridNote.DeleteCommand += new GridCommandEventHandler(RadGridNote_DeleteCommand);
 
        RadGridNote.ID = "RadGridNote";
        RadGridNote.AutoGenerateColumns = false;
        RadGridNote.AllowMultiRowEdit = false;
        RadGridNote.AllowSorting = true;
        RadGridNote.Width = Unit.Percentage(100);       
         
        RadGridNote.ClientSettings.Selecting.AllowRowSelect = true;
 
        RadGridNote.MasterTableView.DataKeyNames = new string[] { "NoteId" };
        RadGridNote.MasterTableView.DataMember = "Note";
 
        RadGridNote.MasterTableView.EditMode = GridEditMode.InPlace;
        RadGridNote.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top;
        RadGridNote.MasterTableView.CommandItemSettings.AddNewRecordText = "Add New Note";
 
        // Edit button.
        editCommandColumn = new GridEditCommandColumn();
        RadGridNote.MasterTableView.Columns.Add(editCommandColumn);
        editCommandColumn.ButtonType = GridButtonColumnType.ImageButton;
        editCommandColumn.UniqueName = "EditCommandColumn";
        editCommandColumn.ItemStyle.Width = Unit.Percentage(10);
 
        // Delete button.
        buttonColumn = new GridButtonColumn();
        RadGridNote.MasterTableView.Columns.Add(buttonColumn);
        buttonColumn.ButtonType = GridButtonColumnType.ImageButton;
        buttonColumn.UniqueName = "DeleteCommandColumn";
        buttonColumn.CommandName = "Delete";
        buttonColumn.ItemStyle.Width = Unit.Percentage(5);
 
        boundColumn = new GridBoundColumn();
        RadGridNote.MasterTableView.Columns.Add(boundColumn);
        boundColumn.ReadOnly = true;
        boundColumn.UniqueName = "NoteId";
        boundColumn.DataField = "NoteId";
        boundColumn.HeaderText = "Id";
        boundColumn.ItemStyle.Width = Unit.Percentage(10);
 
        htmlEditorColumn = new GridHTMLEditorColumn();
        RadGridNote.MasterTableView.Columns.Add(htmlEditorColumn);
        htmlEditorColumn.UniqueName = "NoteText";
        htmlEditorColumn.DataField = "NoteText";
        htmlEditorColumn.HeaderText = "Note";
        htmlEditorColumn.ItemStyle.Width = Unit.Percentage(75);
 
        PlaceHolder1.Controls.Add(RadGridNote);
    }
 
    void RadGridNote_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        RadGridNote.MasterTableView.DataSource = NotesList;       
    }   
 
    void RadGridNote_InsertCommand(object sender, GridCommandEventArgs e)
    {
        GridEditableItem editedItem = e.Item as GridEditableItem;
        GridEditManager editManager = editedItem.EditManager;
 
        Note note = new Note();
 
        note.NoteId = NoteId;
        note.NoteText = (editManager.GetColumnEditor("NoteText") as GridHTMLEditorColumnEditor).Editor.Content;
 
        NotesList.Add(note);
    }   
 
    void RadGridNote_UpdateCommand(object sender, GridCommandEventArgs e)
    {
        GridEditableItem editedItem = e.Item as GridEditableItem;
        GridEditManager editManager = editedItem.EditManager;
 
        // Obtain the ID for the contract step.
        int noteId = int.Parse(editedItem.GetDataKeyValue("NoteId").ToString());
 
        Note foundNote = NotesList.Find(delegate(Note note) { return (note.NoteId == noteId); });
        if (foundNote != null)
        {
            foundNote.NoteText = (editManager.GetColumnEditor("NoteText") as GridHTMLEditorColumnEditor).Editor.Content;
        }
    }
 
    void RadGridNote_DeleteCommand(object sender, GridCommandEventArgs e)
    {
        GridEditableItem editedItem = e.Item as GridEditableItem;
        GridEditManager editManager = editedItem.EditManager;
 
        // Obtain the ID for the contract step.
        int noteId = int.Parse(editedItem.GetDataKeyValue("NoteId").ToString());
 
        Note foundNote = NotesList.Find(delegate(Note note) { return (note.NoteId == noteId); });
        if (foundNote != null)
        {
            NotesList.Remove(foundNote);
        }
    }
 
 
    [Serializable]
    private class Note
    {
        public int NoteId
        {
            get;
            set;
        }
 
        public string NoteText
        {
            get;
            set;
        }
    }
 
}


Any help in resolving this issue would be greatly appreciated.
Thanks,

Tony

5 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 24 Aug 2011, 04:41 PM
Hi Tlp,

I tested the described scenario locally and was able to replicate the issue you mentioned.
I will need some additional time to research on the problem and further debug the issue on my side. I will get back to you with my findings as soon as possible.

Thank you for your report.

Greetings,
Maria Ilieva
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Maria Ilieva
Telerik team
answered on 31 Aug 2011, 03:03 PM
Hello Tlp,

This is to let you know that we further research on the issue and it seems that this is a bug in case InPlace edit form is used. In any other edit modes this scenario works correctly. Find the project attached which presents the correct behaviour without usage of InPlace edit form.
We will log this issue in our system and will do our best to isolate the problem and provide proper fix if possible.
Thank you for reporting this issue.

Kind regards,
Maria Ilieva
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
tlp
Top achievements
Rank 1
answered on 31 Aug 2011, 03:28 PM
Maria,

Thanks for the investigation into the problem and providing a workaround. I would really like to use the InPlace edit mode with the HTML column since, for our particular scenario, it provides a better overall experience when editing the row.

I look forward to a proper fix in one of the future releases.

Thanks,

Tony

0
Chameleoki
Top achievements
Rank 2
answered on 04 Oct 2012, 10:07 PM
I am still experiencing this issue with 2012 Q2.  Any hope to fix this?
0
Maria Ilieva
Telerik team
answered on 10 Oct 2012, 06:46 AM
Hello Cameron,

It appeared that fixing the presented issue is more complex than expected and could cause some breaking change in the RadGrid implementation. However our dev team is still researching on the issue and they will do the best to provide a fix as soon as possible.

Excuse us for any inconvenience caused.

Kind regards,
Maria Ilieva
the Telerik team
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 their blog feed now.
Tags
Grid
Asked by
tlp
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
tlp
Top achievements
Rank 1
Chameleoki
Top achievements
Rank 2
Share this question
or