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

Telerik example ExpandCollapseColumn doesn't work for me

4 Answers 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Myriam
Top achievements
Rank 1
Myriam asked on 19 Sep 2008, 02:13 PM
Hello
I have a RadGrid (with detailtable) which I would like to hide the expandcollapseColumn. I tried the example that I found at this link:
http://www.telerik.com/help/aspnet-ajax/grdpreventgroupsexpansion.html

But it doesn't work for me. Maybe I'm missing something.
Please help!
Here is my code

<telerik:RadGrid DataSourceID="CustomerSource"

ID="RadGrid1"

autogeneratecolumns=False

runat="server" GridLines="None" ShowHeader=false OnColumnCreated="RadGrid1_ColumnCreated" OnPreRender="RadGrid1_PreRender">

<MasterTableView datasourceid="CustomerSource" HierarchyDefaultExpanded=true DataKeyNames="NO_FOURNISSEUR">

<RowIndicatorColumn Visible="False">

<HeaderStyle Width="20px"></HeaderStyle>

</RowIndicatorColumn>

<Columns >

<telerik:GridBoundColumn SortExpression="NO_FOURNISSEUR"

HeaderText="NO_FOURNISSEUR"

DataField="NO_FOURNISSEUR"

UniqueName="NO_FOURNISSEUR"

ReadOnly="true"

Visible="false">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn SortExpression="NOM"

HeaderText="NOM"

DataField="NOM"

UniqueName="NOM"

ReadOnly="true"

Visible="true">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn SortExpression="ADRESSE"

HeaderText="ADRESSE"

DataField="ADRESSE"

UniqueName="ADRESSE"

ReadOnly="true"

Visible="true">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn SortExpression="VILLE"

HeaderText="VILLE"

DataField="VILLE"

UniqueName="VILLE"

ReadOnly="true"

Visible="true">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn SortExpression="CODE_POSTAL"

HeaderText="CODE_POSTAL"

DataField="CODE_POSTAL"

UniqueName="CODE_POSTAL"

ReadOnly="true"

Visible="true">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn SortExpression="NO_TEL1"

HeaderText="NO_TEL1"

DataField="NO_TEL1"

UniqueName="NO_TEL1"

ReadOnly="true"

Visible="true">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn SortExpression="NO_FAX1"

HeaderText="NO_FAX1"

DataField="NO_FAX1"

UniqueName="NO_FAX1"

ReadOnly="true"

Visible="true">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn SortExpression="COURRIEL"

HeaderText="COURRIEL"

DataField="COURRIEL"

UniqueName="COURRIEL"

ReadOnly="true"

Visible="true">

</telerik:GridBoundColumn>

</Columns>

<DetailTables>

<telerik:GridTableView DataKeyNames="No_fournisseur_produit" ShowHeader=true DataSourceID="PanierItemSource" Name="Detail" >

<ParentTableRelation>

<telerik:GridRelationFields DetailKeyField="NO_FOURNISSEUR" MasterKeyField="NO_FOURNISSEUR" />

</ParentTableRelation>

<RowIndicatorColumn Visible="False">

<HeaderStyle Width="20px"></HeaderStyle>

</RowIndicatorColumn>

<Columns>

<telerik:GridButtonColumn ButtonType=LinkButton UniqueName="LkConfirmer" CommandName="ConfirmerUnItem" Text="Confirmer">

</telerik:GridButtonColumn>

<telerik:GridBoundColumn

HeaderText="NO_PANIER"

DataField="NO_PANIER"

UniqueName="NO_PANIER"

ReadOnly="true"

Visible="true">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn SortExpression="CONFIRM"

HeaderText="CONFIRM"

DataField="CONFIRM"

UniqueName="CONFIRM"

ReadOnly="true"

Visible="true">

</telerik:GridBoundColumn>

<telerik:GridTemplateColumn HeaderText="Temp2" UniqueName="Temp2"></telerik:GridTemplateColumn>

</Columns>

<EditFormSettings>

<PopUpSettings ScrollBars="None"></PopUpSettings>

</EditFormSettings>

</telerik:GridTableView>

</DetailTables>

<EditFormSettings>

<PopUpSettings ScrollBars="None"></PopUpSettings>

</EditFormSettings>

<ExpandCollapseColumn Visible=false Resizable=false></ExpandCollapseColumn>

</MasterTableView>

<ClientSettings>

<Resizing AllowColumnResize="True" />

</ClientSettings>

</telerik:RadGrid>

Protected Sub RadGrid1_ColumnCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridColumnCreatedEventArgs) Handles RadGrid1.ColumnCreated

If TypeOf e.Column Is GridGroupSplitterColumn Then

e.Column.HeaderStyle.Width = Unit.Pixel(0)

e.Column.HeaderStyle.Font.Size = FontUnit.Point(0)

e.Column.ItemStyle.Width = Unit.Pixel(0)

e.Column.ItemStyle.Font.Size = FontUnit.Point(0)

e.Column.Resizable =

False

End If

End Sub 'RadGrid1_ColumnCreated



Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.PreRender

For Each column As GridColumn In RadGrid1.MasterTableView.RenderColumns

If (TypeOf column Is GridGroupSplitterColumn) Then

column.HeaderStyle.Width = Unit.Pixel(0)

column.HeaderStyle.Font.Size = FontUnit.Point(0)

column.ItemStyle.Width = Unit.Pixel(0)

column.ItemStyle.Font.Size = FontUnit.Point(0)

column.Resizable =

False

End If

Next

End Sub

4 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 22 Sep 2008, 05:25 AM
Hi Myriam,

The help article that you have refered is on hiding the GroupSplitterColumn of a Grouped Grid. You can try the following code snippet to hide the ExpandCollapse column of a Hierarchical Grid.

CS:
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        RadGrid1.MasterTableView.GetColumn("ExpandColumn").Display = false
         
    } 



Hope this helps
Shinu.
0
Myriam
Top achievements
Rank 1
answered on 22 Sep 2008, 12:15 PM
Thanks again Shinu to help me!
This is working, the only problem is the detail table is too much far from the left side..
Is that I way I can stick it to the left side? something like left margin = 0 ...
Thanks again
0
Accepted
Princy
Top achievements
Rank 1
answered on 22 Sep 2008, 01:26 PM
Hello Myriam,

If you want the detail table to start from the left edge of the parent table, you can try out the following code.
aspx:
<telerik:GridTableView CssClass="Detail" DataSourceID="SqlDataSource1" runat="server" > 
</telerik:GridTableView> 

css:
 <style type="text/css"
  .Detail 
  { 
   position:relative; 
   left:-100px;   
 } 
 </style> 

Princy.

0
Shinu
Top achievements
Rank 1
answered on 23 Sep 2008, 05:46 AM
Hi Myriam,

You can also refer the following help article which explains on aligning Grid columns in each level of Hierarchical Grid.
Aligning columns in each level of hierarchical grid

Cheers
Shinu
Tags
Grid
Asked by
Myriam
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Myriam
Top achievements
Rank 1
Princy
Top achievements
Rank 1
Share this question
or