OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

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 9 years, 8 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #35753

    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
  • #35754

    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.

    #35755

    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"}

    #35756

    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.

    #35757

    Alexandr Smaga
    Participant

    Please try this one:

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

    #35758

    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.

    #35759

    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

    #35760

    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)

The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.

Back to top