hide and display a column in Edit mode in RadGrid

22 posts, 0 answers
  1. Esperanza Ramos
    Esperanza Ramos avatar
    104 posts
    Member since:
    Jul 2012

    Posted 21 Apr 2008 Link to this post

    Hi, All:

    I am using RadGrid.  I want to hide the entire column in normail mode.  But in Edit mode, I want to display this column for editting.

    here is my codes:

    <

    rad:GridTemplateColumn HeaderText="Billed">
    <EditItemTemplate>
    <asp:TextBox ID="tbBilled" runat="server" Text='<%# Bind("Billed", "{0:MM/dd/yyyy}") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="lblBilled" runat="server" Text='<%# Bind("Billed", "{0:MM/dd/yyyy}") %>'></asp:Label>
    </ItemTemplate>
    </rad:GridTemplateColumn>

    Please give some detail on the implementation. 
    Thanks.

    Stanley

  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 22 Apr 2008 Link to this post

    Hi Stanley,

    You can set Display="false" for the column in question. This way, the column will not be shown in normal mode, however the field will be part of the edit form.

    Regards,
    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Esperanza Ramos
    Esperanza Ramos avatar
    104 posts
    Member since:
    Jul 2012

    Posted 22 Apr 2008 Link to this post

    Hi, Team:

    for RecordID or JobID column, which is not displaying normal mode, and should not display in Edit mode.

    <

    rad:GridTemplateColumn HeaderText="JobID" Display="false">
    <EditItemTemplate>
    <asp:Label ID="lblID1" runat="server" Text='<%# Bind("JobID") %>'></asp:Label>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="lblID2" runat="server" Text='<%# Bind("JobID") %>'></asp:Label>
    </ItemTemplate>
    </rad:GridTemplateColumn>

    (1) How to make this column NOT displaying in both normal and Edit mode?

    (2) can it be done in version of Q1 RadControl ASP.NET? (not Ajax)

    Stanley

  5. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 25 Apr 2008 Link to this post

    Hello Stanley,

    In order to hide the column in edit mode as well, set its ReadOnly property to true in addition to Display="false". This method can be used both for RadGrid for ASP.NET and ASP.NET AJAX. For further insight about the ReadOnly/Display/Visible properties of grid columns review this topic from the documentation:

    http://www.telerik.com/help/radcontrols/prometheus/?grdUsingColumns.html (paragraph Visibility and rendering of columns)

    Best regards,
    Stephen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Esperanza Ramos
    Esperanza Ramos avatar
    104 posts
    Member since:
    Jul 2012

    Posted 08 May 2008 Link to this post

    Hi, Telerik Team:

    Thank you for the help.  I had read the document provided by your link.
    I would like to get a confirmation:
       When EditMode="InPlace" for the RadGrid, if a column's Display="False"
        then that column will not be displayed in both normal mode and edit-mode,
        right?

    Thank you.

    Stanley Huang
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 09 May 2008 Link to this post

    Hi Stanley,

    Yes, when EditMode="InPlace" for the RadGrid, if a column's Display="False" then that column will not be displayed in both normal mode and edit-mode. The Display property does not affect the appearance of the column editor in an edit form, but if the grid uses in-place editors, the column editor will not appear.

    Thanks
    Princy.

  8. Esperanza Ramos
    Esperanza Ramos avatar
    104 posts
    Member since:
    Jul 2012

    Posted 09 May 2008 Link to this post

    Hi, Telerik Team:

    Thank you so much.  I got it.

    Stanley Huang
  9. Smiely
    Smiely avatar
    129 posts
    Member since:
    Nov 2010

    Posted 30 Nov 2010 Link to this post

    Hi,

    I want to hide a column in normal as well as in edit(in-form) mode. I am doing that setting visible=False and ReadOnly=True

    But I need to use that value for updating the record.

    If I set ReadOnly=false then only I am able to use that value.

    How can I hide it in both mode as well as use the value?
  10. Smiely
    Smiely avatar
    129 posts
    Member since:
    Nov 2010

    Posted 30 Nov 2010 Link to this post

    I got it !!!!
  11. Andreas Dahlén
    Andreas Dahlén avatar
    16 posts
    Member since:
    Mar 2010

    Posted 12 Jan 2011 Link to this post

    I just came to the same issue, how did you handle it?
  12. Smiely
    Smiely avatar
    129 posts
    Member since:
    Nov 2010

    Posted 13 Jan 2011 Link to this post

    I wanted to use some value from another column to update the record. I have a DropDownList in grid that I am displaying. So I set it's properties. ListTextVaue = what I want to display. ListValueField = to that other value. And it worked for me.
  13. Hakan
    Hakan avatar
    12 posts
    Member since:
    May 2013

    Posted 17 Jul 2013 Link to this post

    Hello Princy,

    It works in EditMode, but in Batch mode, I get weird result. the non-displayed columns appears but their headers are not displayed. Could you give me an advice about it? 
  14. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Jul 2013 Link to this post

    Hi Hakan,

    When we set the display=false, it will hide its display in view mode as well as in editmode.
    Please try the below code snippet.

    ASPX:
    <telerik:RadGrid ID="RadGrid1" runat="server" >
        <MasterTableView  EditMode="Batch">
            <BatchEditingSettings EditType="Cell" />               
            <Columns>
                <telerik:GridBoundColumn DataField="ProductName"  HeaderText="ProductName"
                    UniqueName="ProductName" Display="false">
                </telerik:GridBoundColumn>        
                <telerik:GridNumericColumn DataField="UnitsInStock" ColumnEditorID="NumericEditor1"
                    HeaderText="Units In Stock" UniqueName="UnitsInStock">
                </telerik:GridNumericColumn>
                <telerik:GridBoundColumn DataField="QuantityPerUnit" HeaderText="Quantity Per Unit"
                  ColumnEditorID="TextEditor" UniqueName="QuantityPerUnit" Display="false" >
                </telerik:GridBoundColumn>              
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

    Please elaborate the scenario if this doesn't help.

    Thanks,
    Princy
  15. Hakan
    Hakan avatar
    12 posts
    Member since:
    May 2013

    Posted 18 Jul 2013 Link to this post

    Hello Princy,

    Sorry, I forgot to mention that the problem happens when you click "Add New record". It tries to  show non-displayed fields. I took your sample code, modified a little for my database, and it has the same problem.

    Here is the modified code from your sample. And I attached the visual result of when I click "Add new record" button. You see the textbox at the far right? It appears only when I click around it. It is the textbox of the non-displayed column. How do we fix this?

    Thanks;
     
      <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" AutoGenerateColumns="false" >
        <MasterTableView  EditMode="Batch" CommandItemDisplay="Top">
            <BatchEditingSettings EditType="Cell" />              
            <Columns>
                <telerik:GridBoundColumn DataField="firstName"  HeaderText="firstName"
                    UniqueName="firstName" Display="false">
                </telerik:GridBoundColumn>       
                <telerik:GridNumericColumn DataField="age" ColumnEditorID="NumericEditor1"
                    HeaderText="age" UniqueName="age">
                </telerik:GridNumericColumn>
                <telerik:GridBoundColumn DataField="lastName" HeaderText="lastName"
                  ColumnEditorID="TextEditor" UniqueName="lastName" Display="false" >
                </telerik:GridBoundColumn>             
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
  16. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Jul 2013 Link to this post

    Hi Hakan,

    The display=false will hide the column in view mode as well as edit mode for batch edit.In order to completely hide it,please try setting ReadOnly=True.This will make it hidden for editing or insertion.

    <telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" Display="false" ReadOnly="true"  />

    Hope this helps,

    Thanks
    Princy
  17. Hakan
    Hakan avatar
    12 posts
    Member since:
    May 2013

    Posted 19 Jul 2013 Link to this post

    Thanks Princy, although the style is still messy, the columns disappeared. 
  18. Hakan
    Hakan avatar
    12 posts
    Member since:
    May 2013

    Posted 19 Jul 2013 Link to this post

    Here, check the new screenshot. 

    I set "display : false" and "readonly= true" in the sample. When I click the "add new col" button, it doesn't show the textboxes for non-visible columns anymore, but it still messes the style. (Because it still tries to fit the non-visible columns.)

    Any other idea to how to solve it?


      <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" AutoGenerateColumns="false" >
        <MasterTableView  EditMode="Batch" CommandItemDisplay="Top">
            <BatchEditingSettings EditType="Cell" />              
            <Columns>
                <telerik:GridBoundColumn DataField="firstName"  HeaderText="firstName" ReadOnly="true"
                    UniqueName="firstName" Display="false">
                </telerik:GridBoundColumn>       
                <telerik:GridNumericColumn DataField="age" ColumnEditorID="NumericEditor1"
                    HeaderText="age" UniqueName="age">
                </telerik:GridNumericColumn>
                <telerik:GridBoundColumn DataField="lastName" HeaderText="lastName"
                  ColumnEditorID="TextEditor" UniqueName="lastName" Display="false" ReadOnly="true">
                </telerik:GridBoundColumn>             
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
     
  19. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 22 Jul 2013 Link to this post

    Hi Hakan,

    This seems to be a bug of batch edit .I have tried a workaround.Please try setting the following CSS.

    CSS:
    <style type="text/css">
     .rgMasterTable, .rgClipCells
      {
        table-layout: auto !important;
        width: 102% !important;
      }
    </style>

    Please let me know if any concern.

    Thanks,
    Princy
  20. Hakan
    Hakan avatar
    12 posts
    Member since:
    May 2013

    Posted 22 Jul 2013 Link to this post

    Hey Princy,

    Yeah, I hope you guys fix it as soon as possible, because this batchedit is really great component.

    The style messed my main grid's style, so I give up. Until the bug get fixed, we decided to not put the non-displayable columns for now.
    .  
    Thanks for support.
  21. Angel Petrov
    Admin
    Angel Petrov avatar
    1006 posts

    Posted 22 Jul 2013 Link to this post

    Hi Hakan,

    We have logged this issue into our system and you can monitor it's progress from here. Our developers will do their best to provide a fix as soon as possible.

    Thank you for reporting this to us. As a token of gratitude I have updated your Telerik points.

    Regards,
    Angel Petrov
    Telerik
    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 the blog feed now.
  22. Carlos
    Carlos avatar
    13 posts
    Member since:
    Apr 2015

    Posted 21 May 2015 in reply to Yavor Link to this post

    What if I edit in Batch Mode. is there any option to do same in Batch editing
  23. Angel Petrov
    Admin
    Angel Petrov avatar
    1006 posts

    Posted 26 May 2015 Link to this post

    Hi,

    The problem discussed in the thread concerns the Batch EditMode. Have in mind that it was resolved and if you are using the latest version you should not experience any problems.

    Regards,
    Angel Petrov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017