We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

FilterBar + DataBoundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

8678 Nov 15,2003 12:22 PM Nov 15,2003 02:42 PM Windows Forms 1
loading
Tags: GridControl
Jim Frapper
Asked On November 15, 2003 12:22 PM

It seems, when setting the databound grid property to a dataview the filterbar is lost. For example.... DataView dv = new DataView(ds.Tables["AppointmentByStatusAndGeoID"]); dv.RowFilter = "AppointmentDate > #" + System.DateTime.Today.Date + "# AND " + "AppointmentDate < #" + System.DateTime.Today.Date.AddDays(1) + "#"; this.grdAppointments2.DataSource = dv; //create the filter bar and display it GridFilterBar theFilterBar = new GridFilterBar(); //catch the creating column header event so we can turn off unwanted filter headers //needs to be hooked before WireGrid call to catch things... theFilterBar.CreatingColumnHeader += new GridFilterBarCreatingColumnHeaderEventHandler(GridFilterBarCreatingColumnHeader); //create a style for the filter cells that uses TextBox GridStyleInfo style = new GridStyleInfo(); style.ModifyStyle(this.grdAppointments2.BaseStylesMap["Header"].StyleInfo, StyleModifyType.Copy); style.CellType = "ComboBox"; style.ExclusiveChoiceList = true; style.BaseStyle = "Standard"; style.Font.Bold = false; style.BackColor = this.grdAppointments2.TableStyle.BackColor; style.Borders.Bottom = new GridBorder(GridBorderStyle.Dashed); style.DropDownStyle = GridDropDownStyle.AutoComplete; theFilterBar.WireGrid(this.grdAppointments2, style); The filter bar is not there. If I set the datasource to a datatable then the filterbar shows up. Cheers, JF

Administrator [Syncfusion]
Replied On November 15, 2003 02:42 PM

This is a known limitation. Currently, you can only use either a dataset/datatable or a datatable by itself as the grid's datasource/datamember if you want to use filterbars. You can derive the GridFilterBar class to extend it to support using a DataView as the datasource for the grid. We will add support for using a DataView as the datasource in a future release. Here is some code:
    Public Class SyncGridFilterBar
        Inherits GridFilterBar
        Private _grid As GridDataBoundGrid
        Protected Overrides Function GetDataTable() As DataTable
            If _grid.DataSource Is Nothing Then
                Return Nothing
            End If
            If _grid.DataSource.GetType Is GetType(DataTable) Then
                Return CType(_grid.DataSource, DataTable)
            ElseIf _grid.DataSource.GetType Is GetType(DataView) Then
                Return CType(_grid.DataSource, DataView).Table
            End If
        End Function

        Public Overloads Overrides Sub WireGrid(ByVal grid As GridDataBoundGrid, ByVal style As GridStyleInfo)
            _grid = grid
            MyBase.WireGrid(grid, style)
        End Sub
    End Class

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;