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

Quick Filter Bar

11 Answers 184 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dean
Top achievements
Rank 2
Dean asked on 17 Dec 2010, 12:02 PM
Good Day,

I would like to know if this is currently possible with the RadGrid, Please see image link. I would like a statusbar type control but in the radgrid so when a user adds a filer he will be able to quickly cancel all the filters or just disable/enable the filter quickly.

If it's not possible can you please think of adding it to the next release as this will be a nice user experience addition.

FilterStatus_Image

11 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 17 Dec 2010, 03:00 PM
Hi Dean,

You can do this by adding a RadHostItem to the RadGridView's TableElement, and a RadStatusStrip to the RadHostItem. Have a go with the following code. It's just a RadGridView on a form.

Imports Telerik.WinControls.UI
Imports Telerik.WinControls
  
Public Class Form1
  
    Private m_FilterCancelButton As RadButtonElement
    Private m_FilterLabel As RadLabelElement
  
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  
        Me.RadGridView1.EnableFiltering = True
        Me.RadGridView1.ShowFilteringRow = True
  
        Me.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None
        Me.RadGridView1.Columns.Add(New GridViewTextBoxColumn("Name"))
        Me.RadGridView1.Columns.Add(New GridViewDecimalColumn("Value"))
  
        Dim rowInfo As GridViewRowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A1"
        rowInfo.Cells(1).Value = 3
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A2"
        rowInfo.Cells(1).Value = 4
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A3"
        rowInfo.Cells(1).Value = 5
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A4"
        rowInfo.Cells(1).Value = 6
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A2"
        rowInfo.Cells(1).Value = 4
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A3"
        rowInfo.Cells(1).Value = 5
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A4"
        rowInfo.Cells(1).Value = 6
  
  
        Dim statusBar As New RadStatusStrip()
        statusBar.Dock = DockStyle.Bottom
        statusBar.StatusBarElement.GripStyle = ToolStripGripStyle.Hidden
  
        m_FilterCancelButton = New RadButtonElement()
        m_FilterCancelButton.Text = "-"
        AddHandler m_FilterCancelButton.Click, AddressOf FilterCancelButton_Click
  
        m_FilterLabel = New RadLabelElement()
        m_FilterLabel.Text = " Currently Unfiltered"
  
        statusBar.Items.Add(m_FilterCancelButton)
        statusBar.Items.Add(m_FilterLabel)
  
        Dim hostItem As New RadHostItem(statusBar)
        Me.RadGridView1.TableElement.Children.Add(hostItem)
  
    End Sub
  
    Private Sub FilterCancelButton_Click(ByVal sender As Object, ByVal e As EventArgs)
        Me.RadGridView1.FilterDescriptors.Clear()
    End Sub
  
    Private Sub RadGridView1_FilterExpressionChanged(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.FilterExpressionChangedEventArgs) Handles RadGridView1.FilterExpressionChanged
        If e.FilterExpression.Length > 0 Then
            m_FilterLabel.Text = e.FilterExpression
        Else
            If m_FilterLabel IsNot Nothing Then
                m_FilterLabel.Text = "Currently unfiltered"
            End If
        End If
    End Sub
  
End Class

hope that helps
Richard
0
Dean
Top achievements
Rank 2
answered on 18 Dec 2010, 10:53 AM
Thank you so much for a solution, it works perfectly.
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 13 Apr 2011, 04:00 PM
I'm trying this with 2011Q1 but the status strip first covers the grid, and gets invisible after a refesh. of the grid control.
I would like to have the status strip dock to the bottom, and the grid's table just in the space above it.

Regards
Erwin
0
Richard Slade
Top achievements
Rank 2
answered on 14 Apr 2011, 09:12 AM
Hi Erwin,

Hope you're well. I can see what you mean by it cuts it off at the bottom, though it just seems to be acting like a status bar at the bottom of the form, which doesn't seem to be an issue as far as I can see at the moment. I also cannot get the bar to disappear when anything is refreshed in the latest version of the controls. All seems to work fine.

Can you post a small sample to replicate the problem? If you like, I can add a quick video to show it working here.
Thanks
Richard
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 14 Apr 2011, 04:58 PM
Hi Richard,

thanks for the message. It's not a big issue, I just saw this message and tried it out. In order to place the status bar below the grid and covering it, I tried various stuff and only then did I get the issue of the status bar disappearing.

In my app, until now I use a custom control that contains the grid and has some space below for status messages, buttons etc. This works well, but is a little bit awkward since the custom control has to make the grid public for maximum flexibility. And you then have to access its properties through something like

myControl.Grid.TableElement.....

directly deriving from the grid and add a statusbar seemed more elegant than using a container with the grid and the status bar in it.

Regards
Erwin
0
Richard Slade
Top achievements
Rank 2
answered on 15 Apr 2011, 09:05 AM
Hi Erwin,

Ok, well if I can help in any way just let me know. I guess one could also just use a status bar on the form itself as in a regular way. If you have time at some point to post your own solution too, I'd be interested to see it.

Let me know if I can help though
thanks
Richard
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 15 Apr 2011, 05:29 PM
Of course, Richard - but my app has about 25 grids that need to display status information.

I usually display number of rows in the dataset, number of visible rows in the grid and the time it took to load from the database
so that the user has more feedback about filtered rows and about db performance.
Plus I do show a button that lets the user clear all filters if any are set. (this may become obsolete with newer versions, but the filter UI used to be quite confusing in older versions).

Regards
Erwin
0
Stefan
Telerik team
answered on 18 Apr 2011, 03:00 PM
Hello guys, 

Thank you for this useful discussion. I think that other users might benefit from a code library regarding this subject. 

Here is another approach for arranging the status strip. Please let me know how it works for you:
Imports Telerik.WinControls.UI
Imports Telerik.WinControls
 
Public Class Form1
 
    Private m_FilterCancelButton As RadButtonElement
    Private m_FilterLabel As RadLabelElement
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.RadGridView1.EnableFiltering = True
        Me.RadGridView1.ShowFilteringRow = True
 
        Me.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None
        Me.RadGridView1.Columns.Add(New GridViewTextBoxColumn("Name"))
        Me.RadGridView1.Columns.Add(New GridViewDecimalColumn("Value"))
 
        Dim rowInfo As GridViewRowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A1"
        rowInfo.Cells(1).Value = 3
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A2"
        rowInfo.Cells(1).Value = 4
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A3"
        rowInfo.Cells(1).Value = 5
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A4"
        rowInfo.Cells(1).Value = 6
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A2"
        rowInfo.Cells(1).Value = 4
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A3"
        rowInfo.Cells(1).Value = 5
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A4"
        rowInfo.Cells(1).Value = 6
 
 
        Dim statusBar As New RadStatusStrip()
        statusBar.StatusBarElement.GripStyle = ToolStripGripStyle.Hidden
 
        m_FilterCancelButton = New RadButtonElement()
        m_FilterCancelButton.Text = "-"
        AddHandler m_FilterCancelButton.Click, AddressOf FilterCancelButton_Click
 
        m_FilterLabel = New RadLabelElement()
        m_FilterLabel.Text = " Currently Unfiltered"
 
        statusBar.Items.Add(m_FilterCancelButton)
        statusBar.Items.Add(m_FilterLabel)
 
        Dim hostItem As New RadHostItem(statusBar)
        hostItem.MinSize = New Size(0, 25)
        Me.RadGridView1.GridViewElement.Panel.Children.Insert(1, hostItem)
        Telerik.WinControls.Layouts.DockLayoutPanel.SetDock(hostItem, Telerik.WinControls.Layouts.Dock.Bottom)
 
    End Sub
 
    Private Sub FilterCancelButton_Click(ByVal sender As Object, ByVal e As EventArgs)
        Me.RadGridView1.FilterDescriptors.Clear()
    End Sub
 
    Private Sub RadGridView1_FilterExpressionChanged(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.FilterExpressionChangedEventArgs) Handles RadGridView1.FilterExpressionChanged
        If e.FilterExpression.Length > 0 Then
            m_FilterLabel.Text = e.FilterExpression
        Else
            If m_FilterLabel IsNot Nothing Then
                m_FilterLabel.Text = "Currently unfiltered"
            End If
        End If
    End Sub
End Class

I am looking forward to your reply. 

All the best,
Stefan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Richard Slade
Top achievements
Rank 2
answered on 21 Apr 2011, 10:36 AM
Hi Stefan,

Thanks for the amendment. I will get this submitted as a Code Library project in both VB and C#. For reference though, the click event of the button element doesn't seem to fire when docked in this way. Instead I seem to need to use the MouseDown event.

Regards,
Richard
0
Stefan
Telerik team
answered on 26 Apr 2011, 03:42 PM
Hello Richard, 

Thank you for submitting the Code Library article. 

In regards to the Click event, I will add this to our issue tracking system and we will review it for a future release.
 
Greetings,
Stefan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Richard Slade
Top achievements
Rank 2
answered on 26 Apr 2011, 03:45 PM
Thanks for the update Stefan.
For anyone looking to download this in both CS and VB, the Code Library article is available here

Regards,
Richard
Tags
GridView
Asked by
Dean
Top achievements
Rank 2
Answers by
Richard Slade
Top achievements
Rank 2
Dean
Top achievements
Rank 2
erwin
Top achievements
Rank 1
Veteran
Iron
Stefan
Telerik team
Share this question
or