Search as you type Demo Problem

10 posts, 0 answers
  1. Ludovic Gerbault
    Ludovic Gerbault avatar
    226 posts
    Member since:
    Apr 2009

    Posted 30 Dec 2009 Link to this post

    Hello

    I've tried to implement the functionnality presented in the demo "Search as you type"

    It usually works fine except in one case.
    If there is in the grid a GridViewImageColumn for instance, the whole thing just crash because of a cast exception between GridViewDataColumn and GridViewImageColumn.

    If you change it GridViewColumn, the CreateFilterMethod doesn't work, and if you try to select only the GridViewDataColumn from the RadGrid, ignoring the GridViewImageColumn, then nothing happens when you type.

    Any workaround for that in your minds ?
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 30 Dec 2009 Link to this post

    Hello Subileau Pascal,

    Make the constructor of CustomFilterDescriptor accept an IEnumerable of GridViewColumns.

    Then below, see whether the column is a data column and only if it is, cast it and create a filer on it. Something like this:

    public CustomFilterDescriptor(IEnumerable<GridViewColumn> columns)
    {
        this.compositeFilterDesriptor = new CompositeFilterDescriptor();
        this.compositeFilterDesriptor.LogicalOperator = FilterCompositionLogicalOperator.Or;
     
        foreach (var column in columns)
        {
            GridViewDataColumn dataColumn = column as GridViewDataColumn;
            if (dataColumn != null)
            {
                this.compositeFilterDesriptor.FilterDescriptors.Add(this.CreateFilterForColumn(column));
            }
        }
    }

    I hope this helps.

    Greetings,
    Ross
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Kristof
    Kristof avatar
    10 posts
    Member since:
    Mar 2010

    Posted 24 Mar 2010 Link to this post

    I have also the same problem...

    The search don't work...
    I did the same like in the demo but I used GridViewColumn with images and GridViewDataColumn in my RadGridView.

    The difference with my CustomFilterDescriptor class is that I check if the type of column is GridViewDataColumn.
    But it's also don't work...

    CustomFilterDescriptor class:

    Public Sub New(ByVal columns As IEnumerable(Of GridViewColumn))  
            Me.compositeFilterDesriptor = New CompositeFilterDescriptor()  
            Me.compositeFilterDesriptor.LogicalOperator = FilterCompositionLogicalOperator.[Or]  
     
            Try 
                For Each column As GridViewColumn In columns  
                    Dim dataColumn As GridViewDataColumn = TryCast(column, GridViewDataColumn)  
                    If dataColumn IsNot Nothing Then 
                        Me.compositeFilterDesriptor.FilterDescriptors.Add(Me.CreateFilterForColumn(dataColumn))  
                    End If 
                Next 
            Catch ex As Exception  
                Throw ex  
            End Try 
     
    End Sub 

    Is there a solution?

    Thanks and regards,
    Kristof
  5. Ludovic Gerbault
    Ludovic Gerbault avatar
    226 posts
    Member since:
    Apr 2009

    Posted 24 Mar 2010 Link to this post

    try to select only the GridViewDataColumns which are of type String

    My code looks like this :

    this.ClientsGrid.Columns.OfType<GridViewDataColumn>().Where(x=>x.IsVisible == true && x.DataType == typeof(String))
  6. Kristof
    Kristof avatar
    10 posts
    Member since:
    Mar 2010

    Posted 25 Mar 2010 Link to this post

    I tried the following...

    Public ReadOnly Property CustomFilterDescriptor() As CustomFilterDescriptor  
            Get 
                If Me.m_customFilterDescriptor Is Nothing Then 
                     Dim dataCols = (From col In Me.grdMCPOverview.Columns.OfType(Of GridViewDataColumn)() _  
                     Let dataType = col.DataType _  
                     Where (col.IsVisible) And (dataType Is GetType(String)) _  
                     Select DirectCast(col, GridViewColumn)).ToList()  
                     
                   Me.m_customFilterDescriptor = New CustomFilterDescriptor(dataCols)  
                   Me.grdMCPOverview.FilterDescriptors.Add(Me.m_customFilterDescriptor)  
                End If 
                Return Me.m_customFilterDescriptor  
            End Get 
    End Property 

    But it still don't work...
  7. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 25 Mar 2010 Link to this post

    Hi Kristof,

    Could you please open a separate support ticket and send us a sample project. We will look into it.

    All the best,
    Ross
    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.
  8. Jamest
    Jamest avatar
    41 posts
    Member since:
    Apr 2007

    Posted 04 Jun 2010 Link to this post

    @Subileau Pascal - Thank you,  that fixed my issue of the filtering appearing not to work.
    CustomFilterDescriptor = new CustomFilterDescriptor(this.RadGrid_Packages.Columns.OfType<GridViewDataColumn>().Where(x => x.IsVisible == true && x.DataType == typeof(String))
  9. aubrey
    aubrey avatar
    27 posts
    Member since:
    Apr 2011

    Posted 14 Sep 2011 Link to this post

    hi Subileau,

    how can i select only the GridViewDataColumns which are of type String or int? 
    can you help me figure this out, i've tried it but it doesn't work.

    hoping for your reply,
    Aubrey :)
  10. Ludovic Gerbault
    Ludovic Gerbault avatar
    226 posts
    Member since:
    Apr 2009

    Posted 14 Oct 2011 Link to this post

    Something like

    raddatagrid.Columns.OfType<GridViewDataColumn>().Where(x.DataType == typeof(String) || x.DataType == typeof(Int32))

    Should do the trick :)
  11. Almond
    Almond avatar
    43 posts
    Member since:
    Feb 2011

    Posted 18 May 2012 Link to this post

    Hello Telerik Gurus,

    Can anyone give an example of the below inquiry using EF?

    It will be very much appreciated :)

    Thanks in advance.

    almond
Back to Top
DevCraft banner