ssossossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

Forums Forums OroPlatform OroPlatform – How do I? Questions default for date in DatagridFilter

This topic contains 7 replies, has 4 voices, and was last updated by  miken 3 years, 5 months ago.

  • Creator
    Topic
  • #30105

    mario-seidel
    Participant

    Is it possible to set a default value for date filter in datagrids?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Author
    Replies
  • #30106

    SHAD0WF4X
    Participant

    In my update method is do this:

    This set the createdAt to the current datetime if a entity is created. In your case this would be the default you wanted.

    #30107

    Alexandr Smaga
    Participant

    Hi @mario-seidel!

    Not sure that I got your question correctly.

    Do you want to add some default filtering to grid? You can define default filters under GRID_NAME.filters.default.YOUR_FILTER_COLUMN_NAME : { type: OPERATOR_VALUE, value: "value here"}

    #30108

    mario-seidel
    Participant

    Sorry for the confusing question, i’ll give it a try:
    I have got a datagrid like this:
    columns:
    purchaseDate:
    label: purchase date
    frontend_type: date
    filters:
    columns:
    purchaseDate:
    type: datetime
    data_name: o.purchase_date
    default:
    purchaseDate:
    value: ...?

    When I enter the page the purchaseDate should be prefilled with a default value, for example today. And the datagrid should be already filtered by this value.

    #30109

    Alexandr Smaga
    Participant

    Please try this one:

    where {{2}} means “today”, all variables listed Oro\Bundle\FilterBundle\Provider\DateModifierInterface::VAR_ constants

    #30110

    mario-seidel
    Participant

    That’s what I’m searching for.
    Maybe a more comfortable access to this “function” would be great. But anyway, thank you, this helps alot.

    #30111

    miken
    Participant

    When setting the default like this is there a way to make the visible filter represent the default? The data is filtered correctly for me but the filter above it just says “Date: All” and if I change another filter it shows all dates in the data instead of keeping the default date I set in the datagird.yml

    Thank you,

    Mike

    #30112

    miken
    Participant

    on the latest dev-master the defaults are showing in the filter correctly now. Although when you clear the filter it refreshes and changes to “all” as expected but the results are still based on the original default filter.

Viewing 7 replies - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.