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

hide and display a column in Edit mode in RadGrid

21 Answers 1484 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Esperanza Ramos
Top achievements
Rank 1
Esperanza Ramos asked on 21 Apr 2008, 01:27 PM
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

21 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 22 Apr 2008, 06:24 AM
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
0
Esperanza Ramos
Top achievements
Rank 1
answered on 22 Apr 2008, 07:19 PM
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

0
Sebastian
Telerik team
answered on 25 Apr 2008, 07:13 AM
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
0
Esperanza Ramos
Top achievements
Rank 1
answered on 08 May 2008, 07:56 PM
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
0
Princy
Top achievements
Rank 2
answered on 09 May 2008, 06:10 AM
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.

0
Esperanza Ramos
Top achievements
Rank 1
answered on 09 May 2008, 12:22 PM
Hi, Telerik Team:

Thank you so much.  I got it.

Stanley Huang
0
Smiely
Top achievements
Rank 1
answered on 30 Nov 2010, 08:32 PM
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?
0
Smiely
Top achievements
Rank 1
answered on 30 Nov 2010, 09:05 PM
I got it !!!!
0
Andreas Dahlén
Top achievements
Rank 1
answered on 12 Jan 2011, 03:56 PM
I just came to the same issue, how did you handle it?
0
Smiely
Top achievements
Rank 1
answered on 13 Jan 2011, 03:57 PM
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.
0
Hakan
Top achievements
Rank 1
answered on 17 Jul 2013, 01:12 PM
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? 
0
Princy
Top achievements
Rank 2
answered on 18 Jul 2013, 08:49 AM
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
0
Hakan
Top achievements
Rank 1
answered on 18 Jul 2013, 11:05 AM
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>
0
Princy
Top achievements
Rank 2
answered on 19 Jul 2013, 02:45 AM
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
0
Hakan
Top achievements
Rank 1
answered on 19 Jul 2013, 07:37 AM
Thanks Princy, although the style is still messy, the columns disappeared. 
0
Hakan
Top achievements
Rank 1
answered on 19 Jul 2013, 08:03 AM
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>
 
0
Princy
Top achievements
Rank 2
answered on 22 Jul 2013, 08:58 AM
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
0
Hakan
Top achievements
Rank 1
answered on 22 Jul 2013, 10:48 AM
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.
0
Angel Petrov
Telerik team
answered on 22 Jul 2013, 12:00 PM
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.
0
Carlos
Top achievements
Rank 1
answered on 21 May 2015, 10:50 AM
What if I edit in Batch Mode. is there any option to do same in Batch editing
0
Angel Petrov
Telerik team
answered on 26 May 2015, 06:52 AM
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
Tags
Grid
Asked by
Esperanza Ramos
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Esperanza Ramos
Top achievements
Rank 1
Sebastian
Telerik team
Princy
Top achievements
Rank 2
Smiely
Top achievements
Rank 1
Andreas Dahlén
Top achievements
Rank 1
Hakan
Top achievements
Rank 1
Angel Petrov
Telerik team
Carlos
Top achievements
Rank 1
Share this question
or