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

grid view datetime filter

15 Answers 186 Views
GridView
This is a migrated thread and some comments may be shown as answers.
salini
Top achievements
Rank 1
salini asked on 12 Nov 2010, 08:02 AM
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

15 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 12 Nov 2010, 08:34 AM
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
0
salini
Top achievements
Rank 1
answered on 12 Nov 2010, 08:45 AM
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
0
Emanuel Varga
Top achievements
Rank 1
answered on 12 Nov 2010, 08:48 AM
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
0
salini
Top achievements
Rank 1
answered on 12 Nov 2010, 09:43 AM
 i am using RadControls for WinForms Q2 2010 SP2
0
Emanuel Varga
Top achievements
Rank 1
answered on 12 Nov 2010, 09:45 AM
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
0
salini
Top achievements
Rank 1
answered on 12 Nov 2010, 09:53 AM
yes i am getting the same problem
0
Martin Vasilev
Telerik team
answered on 17 Nov 2010, 09:55 AM
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>>
0
salini
Top achievements
Rank 1
answered on 17 Nov 2010, 09:59 AM
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
0
Martin Vasilev
Telerik team
answered on 22 Nov 2010, 03:02 PM
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.
0
John
Top achievements
Rank 1
answered on 11 Jun 2014, 09:24 PM
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

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 16 Jun 2014, 08:44 AM
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.
 
0
John
Top achievements
Rank 1
answered on 16 Jun 2014, 09:23 PM
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
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 19 Jun 2014, 08:53 AM
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.
 
0
John
Top achievements
Rank 1
answered on 23 Jun 2014, 07:18 PM
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
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 26 Jun 2014, 02:47 PM
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.
 
Tags
GridView
Asked by
salini
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
salini
Top achievements
Rank 1
Martin Vasilev
Telerik team
John
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or