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

Datagrid

3 Answers 105 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 16 Feb 2009, 04:26 PM
Hi

How can I make an extra header line for an existing databound datagridview?
Like grouping.

/Michael

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 17 Feb 2009, 09:51 AM
Hi Michael,

I am not sure what is the exact behavior you want to achieve. Could you please describe it in more details.

You could use the ColumGroupsViewDefinition and create column groups in the header row. Take a look at the "Grid Views" example in our QSF. The following sample demonstrates how to setup this view:

    this.radGridView1.DataSource = table; 
 
    ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition(); 
 
    view.ColumnGroups.Add(new GridViewColumnGroup("User")); 
    view.ColumnGroups.Add(new GridViewColumnGroup("Contact details")); 
 
    view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow()); 
    view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["ID"]); 
    view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Name"]); 
 
    view.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow()); 
    view.ColumnGroups[1].Rows[0].Columns.Add(this.radGridView1.Columns[2]); 
    view.ColumnGroups[1].Rows[0].Columns.Add(this.radGridView1.Columns[3]); 
 
    this.radGridView1.ViewDefinition = view; 
 

I hope this helps. Please feel free to write me back if you have any questions.

Sincerely yours,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Michael
Top achievements
Rank 1
answered on 17 Feb 2009, 11:10 AM
Hi Jack

Thanks for answer.

Thats also the the way I have found to do it.

I have RadGridView2.DataSource = Customer.Data where I have a field called "Date"
When using it, a popup with dates appears. How can change it to use a GridViewMaskBoxColumn1 instead?
It takes the format of the database field.

/Michael
 

 

Just to clarify what I mean

 

--------------------------------------------------
| AB                          | CD                       |
|                               |                             |
--------------------------------------------------
|                |               |            |                  |
|   E          | F             | G        |    H            |
--------------------------------------------------
 
--------------------------------------------------
|                 |                |          |                | Rows
|                 |                |          |                |
--------------------------------------------------
|                 |                |          |                | Rows
|                 |                |          |                |
--------------------------------------------------
|                 |                |          |                | Rows
|                 |                |          |                |
--------------------------------------------------
|                 |                |          |                | Rows
|                 |                |          |                |
--------------------------------------------------
|                 |                |          |                | Rows
|                 |                |          |                |
--------------------------------------------------

--------------------------------------------------
|                 |                |          |                | Rows
|                 |      Total  |    G   |                |
--------------------------------------------------


On rows there should be scroller when add more rows. But header and button row should remain at top/button.

Row E should be a masked date __-__-_____
Row F Text

New rows should just be added when tabbing or arrow down

Hope this give a better picture what I asking about

Me.DataTableAdapter.Fill(Me.Customer.Data)
 Me.RadGridView2.DataSource = Customer.Data

' table view

Me.tableView = CType(Me.RadGridView2.ViewDefinition, TableViewDefinition)
 ' column groups view

Me.columnGroupsView = New ColumnGroupsViewDefinition()
Me.columnGroupsView.ColumnGroups.Add(New GridViewColumnGroup(" "))
Me.columnGroupsView.ColumnGroups.Add(New GridViewColumnGroup("Kasse"))
Me.columnGroupsView.ColumnGroups.Add(New GridViewColumnGroup("Bank"))
Me.columnGroupsView.ColumnGroups.Add(New GridViewColumnGroup("Giro"))
Me.columnGroupsView.ColumnGroups.Add(New GridViewColumnGroup(" "))
Me.columnGroupsView.ColumnGroups(0).Rows.Add(New GridViewColumnGroupRow())
Me.columnGroupsView.ColumnGroups(1).Rows.Add(New GridViewColumnGroupRow())
Me.columnGroupsView.ColumnGroups(2).Rows.Add(New GridViewColumnGroupRow())
Me.columnGroupsView.ColumnGroups(3).Rows.Add(New GridViewColumnGroupRow())
Me.columnGroupsView.ColumnGroups(4).Rows.Add(New GridViewColumnGroupRow())
Me.columnGroupsView.ColumnGroups(0).Rows(0).Columns.Add(Me.RadGridView2.Columns("date"))

RadGridView2.Columns("date").Width = 100
RadGridView2.Columns("date").FormatString = "{0:dd-MM-yyyy}"

Me.columnGroupsView.ColumnGroups(0).Rows(0).Columns.Add(Me.RadGridView2.Columns("Bilagnr"))
Me.columnGroupsView.ColumnGroups(0).Rows(0).Columns.Add(Me.RadGridView2.Columns("tekst"))
Me.columnGroupsView.ColumnGroups(1).Rows(0).Columns.Add(Me.RadGridView2.Columns("Kasse_Indsat"))
RadGridView2.Columns("Kasse_Indsat").HeaderText = "Indsat"
Me.columnGroupsView.ColumnGroups(1).Rows(0).Columns.Add(Me.RadGridView2.Columns("kasse_haevet"))
RadGridView2.Columns("Kasse_haevet").HeaderText = "H‘vet"
Me.columnGroupsView.ColumnGroups(2).Rows(0).Columns.Add(Me.RadGridView2.Columns("Bank_Indsat"))
RadGridView2.Columns("Bank_Indsat").HeaderText = "Indsat"
Me.columnGroupsView.ColumnGroups(2).Rows(0).Columns.Add(Me.RadGridView2.Columns("Bank_haevet"))
RadGridView2.Columns("Bank_haevet").HeaderText = "H‘vet"
Me.columnGroupsView.ColumnGroups(3).Rows(0).Columns.Add(Me.RadGridView2.Columns("Giro_Indsat"))
 

RadGridView2.Columns("Giro_Indsat").HeaderText = "Indsat"

Me.columnGroupsView.ColumnGroups(3).Rows(0).Columns.Add(Me.RadGridView2.Columns("Giro_haevet"))
RadGridView2.Columns("Giro_haevet").HeaderText = "H‘vet"

Me.columnGroupsView.ColumnGroups(4).Rows(0).Columns.Add(Me.RadGridView2.Columns("konto_nr"))
 

RadGridView2.Columns("konto_nr").HeaderText = "Konto nr."

Me.columnGroupsView.ColumnGroups(4).Rows(0).Columns.Add(Me.RadGridView2.Columns("Moms"))

Me.RadGridView2.ViewDefinition = columnGroupsView
 

RadGridView2.MasterGridViewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill

RadGridView2.MasterGridViewTemplate.AllowAddNewRow = True
 

 

 

0
Jack
Telerik team
answered on 18 Feb 2009, 10:49 AM
Hi Michael,

Thank you for writing me back.

If you want to use custom columns you should add them manually. You should set the AutoGenerateColumns property to false and add fill the Columns collection. Take a look at the sample below:

this.radGridView1.MasterGridViewTemplate.AutoGenerateColumns = false
 
GridViewMaskBoxColumn column = new GridViewMaskBoxColumn("DateTime"); 
column.MaskType = MaskType.DateTime; 
this.radGridView1.Columns.Add(column); 
 

Unfortunately, there is an issue that hinders the usage of the GridViewMaskBoxColumn for date time types. We are aware of this issue and plan to address it in our upcoming release.

Currently, you can pin rows only at top of the grid. We will extend this feature in one of our upcoming releases.

Please contact me again if you have any questions.


Best wishes,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Michael
Top achievements
Rank 1
Answers by
Jack
Telerik team
Michael
Top achievements
Rank 1
Share this question
or