
IT Betrieb
Top achievements
Rank 1
IT Betrieb
asked on 29 Nov 2012, 01:17 PM
We're using a GridAttachmentColumn to upload stuff within a databound Grid.
How can I hide this column in View mode and only display it when an item is in Edit mode? We also use InPlace editing and I suppose we would need to rebind the grid. Possible to hide the column via JavaScript?
How can I hide this column in View mode and only display it when an item is in Edit mode? We also use InPlace editing and I suppose we would need to rebind the grid. Possible to hide the column via JavaScript?
6 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 30 Nov 2012, 04:12 AM
Hi,
Please try the following code snippet to show the GridAttachmentcolumn only in edit mode.
C#:
Thanks,
Shinu.
Please try the following code snippet to show the GridAttachmentcolumn only in edit mode.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem && !e.Item.IsInEditMode)
{
GridDataItem DataItem = (GridDataItem)e.Item;
DataItem [
"AttachmentColumnUniqueName"
].Visible =
false
;
}
}
Thanks,
Shinu.
0

IT Betrieb
Top achievements
Rank 1
answered on 30 Nov 2012, 12:07 PM
Hi Shinu,
This hides the data of the column but not the column itself.
Before doing this:
After hiding the AttachmentColumn I get this grid:
The grids' data is shifted one to the left. How would I also delete the column header (just clearing the HeaderText doesn't work - the column still exists)?
This hides the data of the column but not the column itself.
Before doing this:
DataItem [
"AttachmentColumn"
].Visible =
false
;
the RadGrid looks like so:AttachmentColumn TitleColumn CommentColumn
Document.docx My document This is a comment
Excel.xlsx My File Another comment
After hiding the AttachmentColumn I get this grid:
AttachmentColumn TitleColumn CommentColumn
My document This is a comment
My File Another comment
The grids' data is shifted one to the left. How would I also delete the column header (just clearing the HeaderText doesn't work - the column still exists)?
0
Accepted

Shinu
Top achievements
Rank 2
answered on 03 Dec 2012, 05:41 AM
Hi,
Please hide the Header cell as follows.
C#:
Thanks,
Shinu.
Please hide the Header cell as follows.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridHeaderItem)
{
GridHeaderItem HeaderData = (GridHeaderItem)e.Item;
HeaderData [
"AttachmentColumnUniqueName"
].Visible =
false
;
}
}
Thanks,
Shinu.
0

IT Betrieb
Top achievements
Rank 1
answered on 05 Dec 2012, 04:11 PM
Perfect Shinu, now I only need to find out whether the item belonging to the headeritem is in edit mode as I can't do
(again because I only want to hide the Attachment column as well as its header in View mode, in edit mode I want to use it)
&& !e.Item.IsInEditMode
on the HeaderItem, as it never is in edit mode.(again because I only want to hide the Attachment column as well as its header in View mode, in edit mode I want to use it)
0

IT Betrieb
Top achievements
Rank 1
answered on 05 Dec 2012, 07:14 PM
Got it.
I just have to check whether there are any EditIndexes, that way I know whether I am in edit mode. Thanks!
var headerData = e.Item
as
GridHeaderItem;
if
(headerData !=
null
)
{
headerData[
"AttachmentColumnUniqueName"
].Visible = grdIdeaAttachments.EditIndexes.Count != 0;
}
I just have to check whether there are any EditIndexes, that way I know whether I am in edit mode. Thanks!
0

Peter
Top achievements
Rank 1
answered on 06 Dec 2012, 02:45 AM
Thanks for the tip IT Betrieb!