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

column to be hidden only in normal view

2 Answers 32 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joslyn
Top achievements
Rank 1
Joslyn asked on 22 Nov 2013, 01:27 PM
Hi
How to make a column to be hidden in normal view but show in edit form ? I want a column value hidden in view but it should be editable.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Nov 2013, 01:38 PM
Hi Joslyn,

You can set the Visibility of the column to false and in edit mode set it to true. Please try the following code snippet.

ASPX:
<telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID"
    Visible="false" />

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
 {
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {      
        GridEditableItem edit = (GridEditableItem)e.Item;
        edit["OrderID"].Visible = true;
    }
 }

Thanks,
Shinu


0
Viktor Tachev
Telerik team
answered on 27 Nov 2013, 01:53 PM
Hello Joslyn,

In order to hide a column in normal mode of RadGrid you could just set its Visible or Display property to false. There is no need to modify it in the code-behind.

Note that the columns are rendered differently depending on the used property. If Visible is set to false the values from that column are not persisted in the ViewState. If you need to use values from the hidden column you should use the Display property.

On a side note - if you need the reverse option (the column to be visible in normal mode and hidden in edit mode) you could set the ReadOnly property to true.

Regards,
Viktor Tachev
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.
Tags
Grid
Asked by
Joslyn
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Viktor Tachev
Telerik team
Share this question
or