filtering in virtualgrid

4 posts, 1 answers
  1. Rohit
    Rohit avatar
    20 posts
    Member since:
    Dec 2017

    Posted 09 Jan Link to this post

    Hi

    1. If the current filter output has no results, what is the proper way to update the datasource of virtualgrid so that it shows no data message and when the filter is reset, it properly populates the virtualgrid again. I am unable to do so; once an empty dataset is set as source, I am unable to repopulate the virtualgrid when the filter is removed. Can you provide an example which uses datatable as datasource rather than a list (as shown in other examples).

    2. I want to also add my own custom filtering option to imeplement a regex based filtering (similar to contains,startswith etc).How can I do this.

    3. The examples and docs show that data must be re-fetched from the database to update the grid. Since I have millions of rows, I want to know what is the better choice for filtering - re-fetching the data from the database or filtering in-app using LINQ? 

    Thanks.

     

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    2951 posts

    Posted 10 Jan Link to this post

    Hello, Rohit,   

    Thank you for writing.  

    1. It doesn't matter whether you use a DataTable or a List<T>. RadVirtualGrid only uses the CellValueNeeded event to populate the required cell value. It is up to you how exactly you extract the records. I would recommend you to have a look at our Demo application >> VirtualGrid >> Filtering with DataFilter example which demonstrates how to fetch the relevant data considering the filter criteria. If no records match the filter criteria, RadVirtualGrid is displayed empty. The Demo application is located in the installation folder of the suite which is usually located at the following path: C:\Program Files (x86)\Progress\Telerik UI for WinForms R3 2017\Examples\QuickStart\Bin

    2. The filtering behavior in RadVirtualGrid is fully controlled by the developer. Hence, it can be always considered as custom. You select what data exactly to be shown in the grid. The following help article demonstrates a sample approach how to filter the grid: https://docs.telerik.com/devtools/winforms/virtualgrid/filtering/filtering

    3. RadVirtualGrid requires only to specify the rows/columns count. Then, the CellValueNeeded event is fired each time a new cell value is needed when you scroll for example. It is up to you how exactly you will filter and extract the necessary data from your DataSource. RadVirtualGrid gives you the opportunity to fully manage a large amount of data. You can refer to general programming forums like StackOverflow and MSDN where different ideas for filtering millions of records in the DataSource collection are discussed. Thus, you can choose which approach suits your requirement best.

    I hope this information helps. Should you have further questions I would be glad to help.
     
    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Rohit
    Rohit avatar
    20 posts
    Member since:
    Dec 2017

    Posted 10 Jan Link to this post

    Found the problem. I was changing the reference of the datasource rather than adding/deleting the rows from it which was causing it to misbehave.

    Can I add another filter menu option similar to contains,startswith etc. ?

  4. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    2951 posts

    Posted 10 Jan Link to this post

    Hello, Rohit,  

    Thank you for writing back. 

    In order to add a custom item to the filter button's menu, it is suitable to use the ContextMenuOpening event: https://docs.telerik.com/devtools/winforms/virtualgrid/context-menu/modifying-the-default-context-menu

    Here is a sample code snippet how to add a custom item to it. It is up to you what action will be executed when you click the menu item:

    private void radVirtualGrid1_ContextMenuOpening(object sender, Telerik.WinControls.UI.VirtualGridContextMenuOpeningEventArgs e)
    {
        if (e.RowIndex == -3)
        {
            RadMenuItem customMenuItem = new RadMenuItem();
            customMenuItem.Text = "Custom Data Operation";
            RadMenuSeparatorItem separator = new RadMenuSeparatorItem();
            e.ContextMenu.Items.Add(separator);
            e.ContextMenu.Items.Add(customMenuItem);
            customMenuItem.Click+=customMenuItem_Click;
        }
    }



    I hope this information helps. If you have any additional questions, please let me know. 

     Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top