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

Hiding user edit control at start

3 Answers 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kenneth Miller
Top achievements
Rank 1
Kenneth Miller asked on 11 Oct 2017, 12:54 PM

I have a grid component with a user edit ascx control assigned to it. The default behavior, apparently, is for that edit control to be visible when the grid is first loaded/displayed. I do not want it visible. How do I go about hiding it at startup?

 

Here is the ending section of my radgrid definition. Is there something I can do in here to hide that form?

                </Columns>
                <CommandItemSettings ShowAddNewRecordButton="false" />
                <EditFormSettings  UserControlName="DiscountEditor.ascx" EditFormType="WebUserControl" >
                    <EditColumn UniqueName="EditCommandColumn1">
                    </EditColumn>
                </EditFormSettings>
            </MasterTableView>
            <ClientSettings>
                <ClientEvents OnRowDblClick="RowDblClick" OnPopUpShowing="onPopUpShowing" />
            </ClientSettings>
        </telerik:RadGrid>

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 16 Oct 2017, 08:45 AM
Hi Kenneth,

Actually the default behavior is the opposite one - the edit form is not displayed until the user presses the pencil icon/edit button.

Your scenario looks similar to the one shown by the Edit Form Types demo, where the edit form of the second grid row is made editable on page load via the following code:

DefaultCS.aspx.cs
protected void RadGrid1_PreRender(object sender, System.EventArgs e)
{
    if (!this.IsPostBack && this.RadGrid1.MasterTableView.Items.Count > 1)
    {
        this.RadGrid1.MasterTableView.Items[1].Edit = true;
        this.RadGrid1.MasterTableView.Rebind();
    }
}

If you comment out the highlighted row the grid will be rendered as shown in this video: https://www.screencast.com/t/IFTBJHxEb.

You can find more details in the following articles:
Custom Edit Forms
ReadOnly Option for WebUserControl Edit Form 


Best regards,
Rumen
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Kenneth Miller
Top achievements
Rank 1
answered on 16 Oct 2017, 01:06 PM

Thank you. That does appear to have cleared it up. I had this in my PreRender call:

 

    Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.PreRender
        If Not IsPostBack And Me.RadGrid1.MasterTableView.Items.Count > 1 Then
            'Me.RadGrid1.MasterTableView.Items(1).Edit = True
            Me.RadGrid1.MasterTableView.Rebind()
        End If
    End Sub

 

One further question: can you point me toward some example for controlling the position of the user control when it appears?

0
Rumen
Telerik team
answered on 16 Oct 2017, 03:00 PM
Hi,

You can control the position of the UserControl contents via CSS as you would do for every standard HTML element(s). Here is a short video demo: https://www.screencast.com/t/JCrpuRspqr


Best regards,
Rumen
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Kenneth Miller
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Kenneth Miller
Top achievements
Rank 1
Share this question
or