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

Problem with grid horizontal scrollbar

2 Answers 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ericc34
Top achievements
Rank 1
ericc34 asked on 11 Dec 2008, 03:08 PM
Here's my code to create dynamic grid. My grid width is 500px and I have 6 columns of 100px each. My problem is that my grid can't display horizontal scrollbar. Do you know why ?

Me

 

.Grid.Columns.Clear()

 

 

'Set grid settings section

 

 

Me.Grid.Width = Width

 

 

Me.Grid.Height = Height

 

 

Me.Grid.ShowStatusBar = True

 

 

Me.Grid.AutoGenerateColumns = False

 

 

Me.Grid.AllowPaging = False

 

 

Me.Grid.Skin = "Office2007"

 

 

'Set client settings section

 

 

Me.Grid.ClientSettings.Scrolling.AllowScroll = True

 

 

Me.Grid.ClientSettings.Scrolling.UseStaticHeaders = True

 

 

Me.Grid.ClientSettings.Scrolling.ScrollHeight = Height - 20

 

 

'Set mastertableview section

 

 

'Me.Grid.MasterTableView.Width = Unit.Percentage(100)

 

 

Me.Grid.MasterTableView.TableLayout = GridTableLayout.Auto

 

 

Me.Grid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top

 

 

Me.Grid.MasterTableView.EditMode = GridEditMode.InPlace

 

 

Me.Grid.MasterTableView.DataKeyNames = New String() {"ID"}

 

 

'Add GridEditCommandColumn

 

 

Dim EditCommandColumn As GridEditCommandColumn = New GridEditCommandColumn

 

 

Me.Grid.MasterTableView.Columns.Add(EditCommandColumn)

 

EditCommandColumn.ButtonType = GridButtonColumnType.ImageButton

EditCommandColumn.CancelText =

"Annuler la modification de la donn‚e"

 

EditCommandColumn.UniqueName =

"EditCommandColumn"

 

EditCommandColumn.CancelImageUrl =

"../RadControls/Grid/Skins/Outlook/Cancel.Gif"

 

EditCommandColumn.InsertText =

"Ajouter une donn‚e"

 

EditCommandColumn.InsertImageUrl =

"../RadControls/Grid/Skins/Outlook/Update.Gif"

 

EditCommandColumn.UpdateText =

"Mettre … jour la donn‚e"

 

EditCommandColumn.UpdateImageUrl =

"../RadControls/Grid/Skins/Outlook/Update.Gif"

 

EditCommandColumn.EditText =

"Modifier la donn‚e"

 

EditCommandColumn.EditImageUrl =

"../RadControls/Grid/Skins/Outlook/Edit.Gif"

 

EditCommandColumn.HeaderStyle.Width = Unit.Pixel(40)

EditCommandColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Center

 

'Add GridButtonColumn

 

 

Dim GridButtonColumn As GridButtonColumn = New GridButtonColumn

 

 

Me.Grid.MasterTableView.Columns.Add(GridButtonColumn)

 

GridButtonColumn.ButtonType = GridButtonColumnType.ImageButton

GridButtonColumn.CommandName =

"Delete"

 

GridButtonColumn.Text =

"Supprimer la donn‚e"

 

GridButtonColumn.ConfirmText =

"D‚sirez-vous supprimer cette donn‚e ?"

 

GridButtonColumn.ConfirmDialogType = GridConfirmDialogType.RadWindow

GridButtonColumn.UniqueName =

"DeleteColumn"

 

GridButtonColumn.ImageUrl =

"../RadControls/Grid/Skins/Outlook/Delete.Gif"

 

 

If Columns.Count = 0 Then

 

GridButtonColumn.HeaderStyle.Width = Unit.Pixel(100)

 

Else

 

GridButtonColumn.HeaderStyle.Width = Unit.Pixel(20)

 

End If

 

GridButtonColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Center

 

'Add columns to grid

 

 

For Each col As GridColumnDefinition In Columns

 

 

Dim column As GridBoundColumn = New GridBoundColumn

 

 

Me.Grid.MasterTableView.Columns.Add(column)

 

 

If col Is Columns.Last Then

 

 

'column.HeaderStyle.Width = Unit.Percentage(100)

 

 

'column.ItemStyle.Width = Unit.Percentage(100)

 

 

Else

 

column.HeaderStyle.Width = col.Width

column.ItemStyle.Width = col.Width

 

End If

 

column.HeaderText = col.HeaderText

column.DataField = col.Name

column.UniqueName = col.Name

 

Next

 

 

'Add key column

 

 

Dim GridBoundColumn As GridBoundColumn = New GridBoundColumn

 

 

Me.Grid.MasterTableView.Columns.Add(GridBoundColumn)

 

GridBoundColumn.DataField =

"ID"

 

GridBoundColumn.UniqueName =

"ID"

 

GridBoundColumn.Display =

False

 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Dec 2008, 09:27 AM
Hi,

Horizontal scrollbar will be rendered when the total width of the declaratively set columns is greater than  the width of the Grid. In your post you have mentioned that each column is having a width of 100px. In the code provided you have set the width of the column to ' col.Width'. Make sure that the col.Width is equal to 100px.

Shinu
0
ericc34
Top achievements
Rank 1
answered on 12 Dec 2008, 12:57 PM
Total width of all columns are greater then grid width.

Grid width = 500px
Total columns (6) width = 1024px

and I don't see horizontal scrollbar. I see only first three columns and half of 4th and I don't see 5th and 6th column

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