Yii Framework Forum: Yii Advanced Filters - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii Advanced Filters Enter more powerful search terms in grid filters.

#1 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,707
  • Joined: 04-March 10
  • Location:UK

Posted 09 January 2015 - 08:56 AM

This is the discussion topic for the Yii Advanced Filters extension.

The extension allows users to enter more powerful expressions into grid view filters, for example:

word1 word2 word3
- All words must appear in any order.

< 400 & !""
- Numerically less than 400 and not blank.

! /[A-Z]/
- Does not include any letters.

Project page and more examplesTry a demoExtension pageGithub repository

I've put a lot of effort into the documentation, so I hope it'll be easy to install and use. It should also be easy to customise.

Any feedback on the extension and documentation will be appreciated. I'll accept any issues through the GitHub issue tracker. I will also consider pull requests.
0

#2 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,707
  • Joined: 04-March 10
  • Location:UK

Posted 13 January 2015 - 07:06 AM

Date Comparison - Suggestions Welcome

I'm working on the date comparison functions at the moment, but I'd like to get some feedback before proceeding.

By default, the filter will use strtotime() to turn the user entered date into a timestamp, so more natural expressions can be entered. A different function can be provided in config.

---

I'm considering the following patterns:

date - The exact date
date1 to date2 - Between date1 and date2 inclusive

< date - Before the specified date
<= date - On or before the specified date

>= date - On or after the specified date
> date - After the specified date

---

So, for example, you could enter the following filters:

today - Date is today's
>= yesterday - Date is yesterday's or later
> 4th Jan - Date is after 4th Jan this year.
today to today + 7 days - Between today and seven days after today.

Or to prevent any ambiguity:

< 2015-01-25 - before 25th Jan 2015.

---

Problems

  • Very English-centric - PHP's strtotime can only process English date expressions. The implementer can, however, change the function that is used.

  • Natural syntax may cause confusion - if people can enter "today" and other natural language expressions, they might think they can enter "Jan 2014" or "in Jan 2014" or "during Jan 2014" to find any records in January. The first will actually be processed as January 1st and the other two will not be treated as dates at all.


---

I'd welcome any suggestions. I don't want to make the system too confusing.
0

#3 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,707
  • Joined: 04-March 10
  • Location:UK

Posted 15 January 2015 - 03:58 AM

I've uploaded a preview of the date functionality.

Here's the relevant section of the guide.
Here's the updated demo.

In short, it recognises date expressions using PHP's strtotime() function by default and can compare ranges using the same syntax as for numeric ranges. By default, expressions such as the following are supported:

  • = today
    Date is today.
  • > 4th Jan
    Date is after 4th Jan this year.
  • 2015-01-05 to yesterday
    Date is between 5th Jan 2015 and yesterday.


I'm not entirely happy with the syntax, so I'd be happy to receive any feedback. The functionality of the preview is subject to change, so I've not pushed any changes to GitHub yet.
0

#4 User is offline   DottWatson 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 03-August 17

Posted 03 August 2017 - 09:54 AM

Hi,any news for yii2 ?

Thanks
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users