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

[Solved] RadGrid - Grouping - Hiding Expand Collapse Column

5 Answers 737 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ragu
Top achievements
Rank 1
Ragu asked on 21 Jun 2008, 04:48 AM
I am not able to hide the Exand Collapse Column, when i do the Grouping.

This seems like a fooling problem with the Telerik RadGrid, with most of the properties not working from the property settings or thru code behind.

The RadGrid is defined as follows,

I did try the workaround provided in the online help at http://www.telerik.com/help/aspnet-ajax/grdpreventgroupsexpansion.html

Note that, this happens with or without skin. When i have the skin set, it shows the images(+/-) correctly, when i have the skin="" then its not even showing the image from my custom path.

I either need the column to be hidden completely, or if that is not possible then i would need to show my own images.

Need an answer ASAP. Any help from Telerik team is appreciated.

<

telerik:RadGrid

ID="rdStandardReports"

runat="server"

EnableEmbeddedSkins="false"

AutoGenerateColumns="False"

AllowMultiRowSelection="True"

PageSize="1000" GridLines="None" Skin="">

<HeaderStyle BackColor="MidnightBlue"

Font-Bold="True"

Font-Size="8pt"

Font-Italic="False"

Font-Names="Arial"

Font-Overline="False"

Font-Strikeout="False"

Font-Underline="False"

ForeColor="White"

Wrap="True"

HorizontalAlign="Center"

VerticalAlign="Middle" />

<MasterTableView

GridLines="Both"

Font-Names="Arial"

Font-Size="8pt">

<Columns>

<telerik:GridTemplateColumn

UniqueName="selectColumn"

HeaderText="Select">

<HeaderStyle Width="10%" />

<ItemStyle Width="10%" HorizontalAlign="Center" />

<ItemTemplate>

<asp:CheckBox ID="chkProfileId" runat="server" OnCheckedChanged="Report_Selected" AutoPostBack="true" />

</ItemTemplate>

</telerik:GridTemplateColumn>

<telerik:GridHyperLinkColumn

UniqueName="actionColumn"

HeaderText="Action"

Text="Modify"

DataNavigateUrlFields="RPT_SETTINGS_PAGE">

<ItemStyle Width="10%" HorizontalAlign="Center" />

<HeaderStyle Width="10%" />

</telerik:GridHyperLinkColumn>

<telerik:GridBoundColumn

DataField="RPT_NAME"

HeaderText="Report Name"

UniqueName="colRptName">

<ItemStyle Width="60%" />

<HeaderStyle Width="60%" />

</telerik:GridBoundColumn>

<telerik:GridBoundColumn

HeaderText="Last Requested"

UniqueName="colLstRequested"

DataField="RPT_CATEGORY_NAME">

<ItemStyle Width="30%" />

<HeaderStyle Width="30%" />

</telerik:GridBoundColumn>

<telerik:GridBoundColumn

HeaderText="RptPrflId"

UniqueName="colRptPrflId"

DataField="RPT_PROFILE_ID"

Visible="False">

</telerik:GridBoundColumn>

</Columns>

<GroupByExpressions>

<telerik:GridGroupByExpression>

<SelectFields>

<telerik:GridGroupByField FieldName="RPT_CATEGORY_NAME" FieldAlias="RPT_CATEGORY_NAME" HeaderText="RPT_CATEGORY_NAME" />

</SelectFields>

<GroupByFields>

<telerik:GridGroupByField FieldName="RPT_CATEGORY_NAME" FieldAlias="RPT_CATEGORY_NAME" />

</GroupByFields>

</telerik:GridGroupByExpression>

</GroupByExpressions>

<EditFormSettings>

<PopUpSettings ScrollBars="None" />

</EditFormSettings>

<ExpandCollapseColumn

ButtonType="ImageButton"

Resizable="False"

Visible="False"

CollapseImageUrl="../Images/ico_collapse.gif"

ExpandImageUrl="../Images/ico_expand.gif">

<HeaderStyle Width="20px" />

</ExpandCollapseColumn>

<ItemStyle Font-Names="Arial" ForeColor="Black" />

</MasterTableView>

<ClientSettings

AllowExpandCollapse="False"

AllowGroupExpandCollapse="False">

<Selecting EnableDragToSelectRows="False" />

<Resizing AllowColumnResize="True" />

</ClientSettings>

<GroupHeaderItemStyle

Font-Bold="True"

Font-Italic="False"

Font-Names="Arial"

Font-Overline="False"

Font-Strikeout="False"

Font-Underline="False"

ForeColor = "Black"

Wrap="True" />

<GroupPanel Enabled="False">

</GroupPanel>

<ValidationSettings EnableValidation="False" />

</telerik:RadGrid>

5 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 23 Jun 2008, 04:07 PM
Hello Ragu,

Thank you for the code snippet. Here are some notes about your scenario:

1) Concerning the custom images, please note that you should set the ImagesPath property when setting Skin="" or when using a custom non-embedded skin. ImagesPath tells RadGrid where to take all its image buttons from.

<telerik:RadGrid  Skin=""  ImagesPath="~/..../"  />


2) As for the ability to hide the column, I will check how this should be done and will write again. Thank you for your patience.


Greetings,
Dimo
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Dimo
Telerik team
answered on 24 Jun 2008, 12:49 PM
Hi Ragu,

This is a follow-up message.

In order to hide the expand/collapse column, please use :

ASPX

<telerik:RadGrid 
    ID="RadGrid1" 
    OnColumnCreated="RadGrid1_ColumnCreated" 
    OnItemCreated="RadGrid1_ItemCreated" /> 

C#

protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) 
{ 
    if (e.Column is GridGroupSplitterColumn) 
    { 
        e.Column.HeaderStyle.Width = Unit.Pixel(0); 
        e.Column.HeaderStyle.Font.Size = FontUnit.Point(1); 
        e.Column.ItemStyle.Width = Unit.Pixel(0); 
        e.Column.ItemStyle.Font.Size = FontUnit.Point(1); 
        e.Column.Resizable = false; 
    } 
} 
 
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
{ 
    if (e.Item is GridGroupHeaderItem) 
    { 
        (e.Item as GridGroupHeaderItem).Cells[0].Controls[0].Visible = false; 
    } 
} 


If you want to access and customize the expand/collapse image buttons' URLs, you can use the ColumnCreated event handler as well:


C#

protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) 
{ 
    if (e.Column is GridGroupSplitterColumn) 
    { 
        (e.Column as GridGroupSplitterColumn).ExpandImageUrl = "....."; 
        (e.Column as GridGroupSplitterColumn).CollapseImageUrl = "....."; 
    } 
} 
 



Kind regards,
Dimo
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ragu
Top achievements
Rank 1
answered on 30 Jun 2008, 02:20 PM
Thanks for your response... I did figure this out over the weekend after posting the question on the forum on a friday night. Question is, can this be made to avoid the ImagesPath property, if we give the image name with the Path in the Expand / Collapse ImageUrl itself.

And another thing is why is that it is expecting us to have the same image name.? Can this be made to take any image name.

Things like this would make the developers job easier, rather than going thru 100s of help and forums to figure this out.

I hope the Telerik Team understand the point that i am trying to convey.
0
Ragu
Top achievements
Rank 1
answered on 30 Jun 2008, 02:26 PM
As i mentioned in my post the code snippet that you have provided is available on the on-line help except the code to set font size to 1 pt.

protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) 
{ 
    if (e.Column is GridGroupSplitterColumn) 
    { 
        e.Column.HeaderStyle.Width = Unit.Pixel(0); 
        e.Column.HeaderStyle.Font.Size = FontUnit.Point(1); 
        e.Column.ItemStyle.Width = Unit.Pixel(0); 
        e.Column.ItemStyle.Font.Size = FontUnit.Point(1); 
        e.Column.Resizable = false; 
    } 
} 

Please check and update the help at
http://www.telerik.com/help/aspnet-ajax/grdpreventgroupsexpansion.html

The question is when we have a property AllowExpandCollapse property, why cant the Expand Collapse column made visible or invisible based on that.

"Because the above code is a workaround and not a direct solution".

Hope the Telerik Team understands this.
0
Dimo
Telerik team
answered on 01 Jul 2008, 12:52 PM
Hello Ragu,

Here are the answers to your questions:

1) can this be made to avoid the ImagesPath property, if we give the image name with the Path in the Expand / Collapse ImageUrl itself.

==> Yes. The ImagesPath property is not always necessary, it was created to simplify things - for example to tell RadGrid where all its images are, instead of declaring each image separately.



2)
And another thing is why is that it is expecting us to have the same image name.? Can this be made to take any image name.

== > If you are using ImagesPath, you are specifying only a folder, no filenames. That is why RadGrid expects to find files with predefined filenames there. If you specify an image separately, you can give it any name.


3)
The question is when we have a property AllowExpandCollapse property, why cant the Expand Collapse column made visible or invisible based on that.

Well, this is by design - the property allows an action, but does not control objects' visibility.


Yes, we will update our help article.


Kind regards,
Dimo
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Ragu
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Ragu
Top achievements
Rank 1
Share this question
or