in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

Display Column only when Adding / Editing

Last post 11/20/2008 7:22 AM by Timothy McCurdy. 4 replies.
Page 1 of 1 (5 items)
Sort Posts:
Previous Next
  • 11/17/2008 1:59 PM

    Display Column only when Adding / Editing

    I'd like to display a "Description" column in the "Preview" of each Row in the ASPxGrid (8.2.6).  However, when the User Adds / Edits a Row, I want that "Description" column to be editable and display in a MemoEdit.  Is this possible?

     

  • 11/18/2008 6:01 PM In reply to

    Re: Display Column only when Adding / Editing

    Hi Timothy,

    Use the PreviewRow and set up your grid like the following:

            <asp:AccessDataSource ID="AccessDataSource1" runat="server" 
                DataFile="~/App_Data/nwind.mdb" 
                SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]">
            </asp:AccessDataSource>
            <dxwgv:ASPxGridView ID="ASPxGridView1" runat="server" 
                AutoGenerateColumns="False" DataSourceID="AccessDataSource1" 
                KeyFieldName="CategoryID" PreviewFieldName="Description">
                <Settings ShowPreview="True" />
                <Columns>
                    <dxwgv:GridViewCommandColumn VisibleIndex="0">
                        <EditButton Visible="True">
                        </EditButton>
                    </dxwgv:GridViewCommandColumn>
                    <dxwgv:GridViewDataTextColumn FieldName="CategoryID" ReadOnly="True" 
                        VisibleIndex="1">
                        <EditFormSettings Visible="False" />
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn FieldName="CategoryName" VisibleIndex="2">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataMemoColumn FieldName="Description" Visible="False" 
                        VisibleIndex="3">
                        <EditFormSettings Visible="True" />
                    </dxwgv:GridViewDataMemoColumn>
                </Columns>
            </dxwgv:ASPxGridView>
    

     

     

  • 11/19/2008 8:17 AM In reply to

    Re: Display Column only when Adding / Editing

    Right, that's what I ended up doing, however, my requirements are that the RowEditing be done "Inline".  The "EditFormSettings" do not take effect with Inline-Editing.  May I make a suggestion that there be an additional <InlineEditSettings> tag? Big Smile

  • 11/19/2008 6:38 PM In reply to

    Re: Display Column only when Adding / Editing

    Hi Tim,

    Found an answer. Set the visible property to false and enable it using Nathan's approach in this post: How to hide a column in inline edit mode

    Except change true/false since you're showing instead of hiding the column.

     

  • 11/20/2008 7:22 AM In reply to

    Re: Display Column only when Adding / Editing

    Answer

    Amazing!  It works!  Still, it might be easier if there were a <InlineEditSettings> tag for each Column just like the <EditFormSettings> tag Stick out tongue.

     

    protected void OnGridStartRowEditing(object sender, ASPxStartRowEditingEventArgs e)
    {
         ((ASPxGridView)sender).Columns["Description"].Visible = true;
    }

    protected void OnGridAfterPerformCallback(object sender, ASPxGridViewAfterPerformCallbackEventArgs e)
    {
         if (e.CallbackName == "CANCELEDIT" || e.CallbackName == "UPDATEEDIT")
              ((ASPxGridView)sender).Columns["Description"].Visible = false;
    }

Page 1 of 1 (5 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED