HowTo: C1TrueDBGrid Datacolumn Syntax of FilterOperator to filter Date Values

Posted by: SHanau on 11 November 2022, 2:52 pm EST

    • Post Options:
    • Link

    Posted 11 November 2022, 2:52 pm EST

    Hi There,

    Firstly: Could you please provide a sample showing what kind of FilterOperator I’d have to use to filter a datacolumn with underlying date values?

    Secondly: Is there an automatic translation of entries like ‘31.12.2022’ (with german syntax and german date separators) into a valid filter statement? Or do I have to do it manually?

    Thanks in advance,

    Stephan

  • Posted 14 November 2022, 6:29 am EST

    Hi Stephan,

    In the C1TrueDBGrid, the filtering is passed on to the underlying DataSource. In the case of a DataTable as DataSource, the DataTable.DefaultView.RowFilter property is used for filtering the View. Internally, the Grid uses a string similar to

    ([Joining Date] >= #06/22/2018# AND [Joining Date] < #06/23/2018#)

    to filter the DataColumns of DateTime DataType.

    Also, if the C1TrueDBGrid is used in a German environment (‘.’ character is the Date separator), the Grid automatically handles it internally and creates a Filter string similar to above only.

    Kindly refer to the attached sample (also contains the screenshots) showing a simple implementation of the same.

    Attachment: DateFiltering_Tdbg.zip

    Best Regards,

    Kartik

  • Posted 14 November 2022, 8:25 am EST

    Hi Kartik,

    Thank you very much for your quick response. I really appreciate it.

    Your sample has helped me a lot figuring out what my problem with automatic filtering was and I think, I might have stumbled over a small bug:

    I set the NumberFormat property of the data column to “FormatText Event”. Looking into the automatically generated filter string it showed this:

    CONVERT([kk_datum], System.String) LIKE '%or0aTex Even%'

    which I consider as a bug.

    After having set the NumberFormat to “Short Date” filtering worked like a charm:

    ([kk_datum] >= #04/04/2022# AND [kk_datum] < #04/05/2022#)

    Initially I applied “FormatText Event” to the NumberFormat property because I wanted to translate certain dates into a different syntax. I realize now that I can achieve the same behaviour by using the column’s ValueItems collection instead.

    Problem solved. Thanks very much,

    Stephan

  • Posted 15 November 2022, 12:15 am EST

    Hi Stephan,

    We are glad to hear that your issue is resolved. Let us know if you face any other issues OR if you need any other information.

    Regards,

    Kartik

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels