Moving the Edit Form (for IsItemInserted) Above Column Headers and Hiding Command Item

2 posts, 0 answers
  1. Merritt
    Merritt avatar
    28 posts
    Member since:
    Mar 2011

    Posted 15 Mar 2012 Link to this post

    Simple scenario: I want the edit form to appear above the column headers and I also want to hide the command item "row". I am not looking for a solution involving modals or placing the form outside of the radgrid.

    Here's my code so far:

    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            RadGrid1.MasterTableView.IsItemInserted = true;
            RadGrid1.Rebind();
        }
     
        GridCommandItem commandItem = RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0] as GridCommandItem;
        commandItem.Visible = !RadGrid1.MasterTableView.IsItemInserted;
     
        if (!commandItem.Visible) // If edit form is open
        {
            GridEditFormItem editFormItem = RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem)[0] as GridEditFormItem;
     
            editFormItem.Parent.Controls.Remove(editFormItem);
            commandItem.Parent.Controls.AddAt(0, editFormItem);
        }
    }

    But during asynch postbacks all goes to hell: the edit form disappears.
  2. Tsvetina
    Admin
    Tsvetina avatar
    1874 posts

    Posted 20 Mar 2012 Link to this post

    Hello Merritt,

    Your requirement is not supported in RadGrid and cannot be achieved without taking the edit form out of RadGrid. Doing such changes in the control structure will break the ViewState and the code used to address the editing procedures.

    Greetings,
    Tsvetina
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top