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

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

1 Answer 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Merritt
Top achievements
Rank 1
Merritt asked on 15 Mar 2012, 05:57 PM
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.

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 20 Mar 2012, 01:51 PM
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.
Tags
Grid
Asked by
Merritt
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or