grid view datetime filter

16 posts, 0 answers
  1. salini
    salini avatar
    1 posts
    Member since:
    Oct 2010

    Posted 12 Nov 2010 Link to this post

    i am getting only null and not null filters on a datetime column and price column of double datatype
    why is it so?
    i want other filters too.
    plz help
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 12 Nov 2010 Link to this post

    Hello Salini,

    Which version of telerik controls are you using?
    Using Q3 version and this code:
    using System;
    using System.ComponentModel;
    using System.Windows.Forms;
    using Telerik.WinControls.UI;
     
    public partial class Form1 : Form
    {
        private RadGridView radGridView1;
     
        public Form1()
        {
            InitializeComponent();
            this.Controls.Add(radGridView1 = new RadGridView());
            radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
            radGridView1.Dock = DockStyle.Fill;
        }
     
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            radGridView1.EnableFiltering = true;
            radGridView1.DataSource = new Tests(10);
        }
    }
     
    public class Test
    {
        public double DoubleColumn
        {
            get;
            set;
        }
     
        public DateTime DateColumn
        {
            get;
            set;
        }
     
        public Test(int no)
        {
            DoubleColumn = no;
            DateColumn = DateTime.Now.AddDays(no);
        }
    }
     
    public class Tests : BindingList<Test>
    {
        public Tests(int noItems)
        {
            for (int i = 0; i < noItems; i++)
            {
                this.Add(new Test(i));
            }
        }
    }

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  3. UI for WinForms is Visual Studio 2017 Ready
  4. salini
    salini avatar
    1 posts
    Member since:
    Oct 2010

    Posted 12 Nov 2010 Link to this post

    i m still not getttin other filters
    i m using a generic list as a data source to the grid view
    i  am getting all the filters for other columns in the grid but only for a datetime column and double type column i am not getting all the filters.

    is there some properties i need to check for these two column types
  5. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 12 Nov 2010 Link to this post

    Hello again,

    Can you please tell me which version are you using? and if you are not using Q3 version i would suggest updating to the latest version.

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  6. salini
    salini avatar
    1 posts
    Member since:
    Oct 2010

    Posted 12 Nov 2010 Link to this post

     i am using RadControls for WinForms Q2 2010 SP2
  7. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 12 Nov 2010 Link to this post

    Ok, this might sound strange, but can you please remove the grid and add another one from the toolbox and tell me if you have the same issue.

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  8. salini
    salini avatar
    1 posts
    Member since:
    Oct 2010

    Posted 12 Nov 2010 Link to this post

    yes i am getting the same problem
  9. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 17 Nov 2010 Link to this post

    Hi salini,

    Thank you for writing.

    Do you use Nullable DateTime type (DateTime?) in your generic list ? If this is the case, in our previous versions we had some issues with Nullable types and filtering menu items. The good news is that we have already addressed that in Q3 2010. I would recommend that you download the new release and give it a try.

    Let me know if you still experience any issues.

    Best wishes,
    Martin Vasilev
    the Telerik team
    See What's New in RadControls for WinForms in Q3 2010 on Wednesday, November 17, 11am Eastern Time: Register here>>
  10. salini
    salini avatar
    1 posts
    Member since:
    Oct 2010

    Posted 17 Nov 2010 Link to this post

    sorry,i am informing u late
    actually i have solved that problem

    i have another problem now
    i am working on windows forms
    can u send me the code for adding filters as shown in the figure i have attached.
    please reply soon
  11. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 22 Nov 2010 Link to this post

    Hello salini,

    Thank you for getting back to me.

    You can enable excel-like filtering by using the following code:

    this.radGridView1.EnableFiltering = true;
    this.radGridView1.ShowFilteringRow = false;
    this.radGridView1.ShowHeaderCellButtons = true;

    Let me know if you need any additional assistance.

    Kind regards,
    Martin Vasilev
    the Telerik team
    Get started with RadControls for WinForms with numerous videos and detailed documentation.
  12. John
    John avatar
    21 posts
    Member since:
    Sep 2013

    Posted 11 Jun 2014 Link to this post

    Hi,
    For a gridview datetime columns  how can I get "between", "greater than" and "less than" options in Available Filters menu (or somewhere else) - similar to the options for gridview numeric columns?  Currently only text type filters (starts with, contains, equals, etc.) show up.
    Thanks a lot,
    John

  13. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 16 Jun 2014 Link to this post

    Hello John,

    Thank you for writing.

    GridViewDateTimeColumn provides date entry and formatting for DateTime data types. This column type does support filtering data using "between", "greater than" and "less than" options. I have attached a sample project, which behavior is demonstrated in the attached gif file.  

    I hope this information helps. Should you have further questions, I would be glad to help.

    Regards,
    Desislava
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  14. John
    John avatar
    21 posts
    Member since:
    Sep 2013

    Posted 16 Jun 2014 in reply to Dess Link to this post

    Hi Desislava, 
    Thanks for your reply.  I see from your example that there are numeric type filters for true datetime columns.  The problem is my data comes from a nvarchar type data column but is in date format - actually all the data is in a single column and is pivoted before display.  I am setting .AutoGenerateColumns=False and creating the columns manually.  When I create a gridviewdatetimecolumn  and bind the 'date' column to it I get a hybrid type filter with a calendar where I can pick specific single dates but no 'between' in the available filters - see attached. Also sorting is alphabetical, not by date.   I tried adding a new calculated  datetime column to the datatable and using it iin the grid instead of the text field but have not been able to see data in the datetime column.  ANy ideas how to get date-like filtering/sorting for this column?
    Thanks,
    John
  15. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 19 Jun 2014 Link to this post

    Hello John,

    Thank you for writing back.

    In order to obtain the desired filtering options and sorting behavior, you can manually add the GridViewDateTimeColumn with the appropriate FieldName. However, the inserted string should contain a full DateTime representation, e.g. "6/23/2014 11:32:10 AM". Otherwise, you should specify the GridViewDateTimeColumn.DataType property to has value typeof(DateTime). I have prepared a sample project, where the RadGridView is bound to a list of custom objects, where the custom object contains two date properties, one of which is typeof(string) and the other is typeof(DateTime).

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

    Regards,
    Desislava
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  16. John
    John avatar
    21 posts
    Member since:
    Sep 2013

    Posted 23 Jun 2014 in reply to Dess Link to this post

    Thanks Desislava.  
    Setting the DataType property to datetime gets me the filters I need.  However it is still sorting by string. How can I get it to sort by datetime?
    Thanks,
    John
  17. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 26 Jun 2014 Link to this post

    Hello John,

    Thank you for writing back.

    It is possible to implement sorting not by string but by DateTime representation using Custom Sorting.

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

    Regards,
    Desislava
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top
UI for WinForms is Visual Studio 2017 Ready