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
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
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
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
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
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.
Thank you so much. I got it.
Stanley Huang
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?
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
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
>
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
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
>
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
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.
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
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