yii gridview is powerful, but time filtering is troublesome, which is related to the storage format of the database. The time format of this article is date type. This article mainly introduces in detail the time period filtering function of yii gridview, an input box, and automatic submission. The function has certain reference value. Interested friends can refer to it. I hope it can help everyone.
Then the problem comes, Yii only provides text search format about time, that is, it can only find precise dates such as 2017-8-10. Almighty's customer said this won't work, I want to search for a time period! I just want an input box! I want to submit automatically!
Points to note:
1. First, introduce relevant js into the gridview to implement double dates. Here we chose jquery.daterangepicker.js , simple and generous (disadvantages: you cannot select the year, you need to click manually, I will not greatly span the years here, it is available)
2. To process the data in the search model, perform time query
3. Pitfall: After selecting the date, the input box has no cursor, and you need to click twice and then press Enter to refresh the data, which is quite different from the original gridview experience.
4. Ladder: When the input date data is detected Finally, use jq to simulate the carriage return submission action, perfectly realizing the original experience similar to gridview, silky smooth
view
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
demo.js At the end, let’s talk about PatentDataBdSearch. It processes the data sent from the input box and queries the database during the time period.
1 2 3 4 5 |
|
demo.js implements data detection and simulates the carriage return operation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
Related recommendations;
js setinterval method to modify the running time period
Javascript implements the method of displaying greetings according to the time period
javascript implementation code for judging the time period
The above is the detailed content of Detailed explanation of examples of time period filtering function in yii gridview. For more information, please follow other related articles on the PHP Chinese website!