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

[Solved] Problem with grid mastertableview width

6 Answers 261 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ericc34
Top achievements
Rank 1
ericc34 asked on 12 Jun 2008, 06:32 PM
I have a grid in which I add column dynamically. Actually I add 10 columns of 100 pixels each. I also set my mastertableview to 1000 pixels. My gris is 500 pixels width. Actually I see only half of my last column. I don't know why. If my calcul is good, 10 x 100 pixels equal 1000 pixels. What's wrong ?

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Jun 2008, 05:18 AM
Hi,

Try increasing the Width of the Grid from 500px to 1000px and see whether the Edit column is appearing or not.

ASPX:
<telerik:radgrid id="RadGrid1" runat="server" Width="1000px"  > 
    <MasterTableView  Width="1000px"     > 
 


Shinu.
0
ericc34
Top achievements
Rank 1
answered on 13 Jun 2008, 11:45 AM
I only see half of my last column but I'm sure all columns make 1000px.
0
Demon
Top achievements
Rank 1
answered on 13 Jun 2008, 11:54 AM
Do you have some special columns visible, for example a RowIndicator column ora  Group Expand/Collapse column?
0
ericc34
Top achievements
Rank 1
answered on 13 Jun 2008, 12:00 PM
I have no special column. Here's my grid definition :

<

telerik:RadGrid ID="Grid" runat="server" Skin="Outlook" GridLines="None" EnableAjaxSkinRendering="true">

<MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" EditMode="InPlace" >

<CommandItemTemplate>

<asp:LinkButton ID="lnkBtnAddData" runat="server" CommandName="InitInsert" Visible="true"><img style="border:0px;vertical-align:middle;" alt="" src="../images/AddRecord.Gif" />

<asp:Literal ID="litAddData" runat="server" Text="Ajouter une donn‚e"></asp:Literal>

</asp:LinkButton>

</CommandItemTemplate>

<Columns>

<telerik:GridEditCommandColumn ButtonType="ImageButton" CancelText="Annuler la modification de la colonne"

UniqueName="EditCommandColumn" CancelImageUrl="../RadControls/Grid/Skins/Outlook/Cancel.Gif"

FilterImageUrl="" InsertText="Ajouter une colonne" InsertImageUrl="../RadControls/Grid/Skins/Outlook/Update.Gif"

SortAscImageUrl="" SortDescImageUrl="" UpdateText="Mettre … jour la colonne"

UpdateImageUrl="../RadControls/Grid/Skins/Outlook/Update.Gif" EditText="Modifier la colonne"

EditImageUrl="../RadControls/Grid/Skins/Outlook/Edit.Gif">

<HeaderStyle Width="40px" />

<ItemStyle HorizontalAlign="Center" Width="40px"/>

</telerik:GridEditCommandColumn>

<telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" Text="Supprimer la colonne" ConfirmText="D‚sirez-vous supprimer cette colonne ?" ConfirmDialogType="RadWindow"

UniqueName="DeleteColumn" ImageUrl="../RadControls/Grid/Skins/Outlook/Delete.Gif">

<HeaderStyle Width="20px" />

<ItemStyle HorizontalAlign="Center" />

</telerik:GridButtonColumn>

</Columns>

<NoRecordsTemplate>

<asp:Label ID="lblNoRecordsTemplate" runat="server" Text="Aucun enregistrement"></asp:Label>

</NoRecordsTemplate>

<ItemStyle Font-Names="Tahoma" Font-Size="8pt" />

</MasterTableView>

</

telerik:RadGrid>

Now I add 10 columns like this :

For Each col As GridColumnDefinition In Columns
Dim column As GridBoundColumn = New GridBoundColumn
column.HeaderStyle.Width = col.Width
column.HeaderText = col.HeaderText
column.DataField = col.Name
column.UniqueName = col.Name
Me.Grid.MasterTableView.Columns.Add(column)
Next

Theses 10 columns has a total width of 940px. Theses 10 colums + 2 editcommandcolumn (40px and 20px) do a total of 1000px

0
Shinu
Top achievements
Rank 2
answered on 16 Jun 2008, 06:53 AM
Hi,

Since you  have created the RadGrid statically and adding its structure dynamically first add the Column to the column collection and then set its properties.

CS:
private void Page_Load(object sender, System.EventArgs e) 
{ 
 if ( !IsPostBack ) 
 { 
   GridBoundColumn boundColumn; 
 
   //Important: first Add column to the collection 
   boundColumn = new GridBoundColumn(); 
   this.RadGrid1.MasterTableView.Columns.Add(boundColumn); 
 
   //Then set properties 
   boundColumn.DataField = "CustomerID"; 
   boundColumn.HeaderText = "CustomerID"; 
 } 
} 
            


Shinu.
0
ericc34
Top achievements
Rank 1
answered on 16 Jun 2008, 12:02 PM

Here's how I add my column dynamically. What's wrong ?

'Remove add data button

If Not EnableInsertButton Then
Me.Grid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None
End If
Me.Grid.Width = Width
Me.Grid.Height = Height

'Set client settings section
Me.Grid.ClientSettings.Scrolling.AllowScroll = True
Me.Grid.ClientSettings.Scrolling.UseStaticHeaders = True
Me.Grid.ClientSettings.Scrolling.ScrollHeight = Height - 20

'Add columns to grid
Dim MasterTableViewWidth As Integer = 0
For Each col As GridColumnDefinition In Columns
Dim column As GridBoundColumn = New GridBoundColumn
Me.Grid.MasterTableView.Columns.Add(column)
column.HeaderStyle.Width = col.Width
column.HeaderText = col.HeaderText
column.DataField = col.Name
column.UniqueName = col.Name
MasterTableViewWidth += col.Width
Next

'Set mastertableview section
Me.Grid.MasterTableView.Width = Unit.Pixel(MasterTableViewWidth)
Me
.Grid.MasterTableView.TableLayout = GridTableLayout.Fixed

Tags
Grid
Asked by
ericc34
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
ericc34
Top achievements
Rank 1
Demon
Top achievements
Rank 1
Share this question
or