date - filer using a date value using equals, between, before and after condition logic.
created_at:
label: Created
type: date以下属性可用于筛选器。
| Property | Description |
|---|---|
| minDate | the minimum/earliest date that can be selected. |
| maxDate | the maximum/latest date that can be selected. |
| firstDay | the first day of the week. Default: 0 (Sunday). |
| showWeekNumber | show week numbers at head of row. Default: false |
| useTimezone | convert the date and time from the backend specified timezone preference. Default: true |
| conditions | for each condition, set to true or false to make it available, or as a string, can be custom SQL statement for selected conditions. Default: true. |
以下 条件 可用于过滤。
| Condition | Description |
|---|---|
| equals | is within the selected date from start to end of day |
| notEquals | is not within the selected date from start to end of day |
| between | is between the two selected dates |
| before | is before the selected date |
| after | is after the selected date |
筛选后的值会自动转换为后端时区偏好设置,您可以使用 useTimezone 选项禁用此功能。
created_at:
label: Created
type: date
useTimezone: false若要仅允许查找确切日期 将 equals 作为 条件 传递。 若要查找包含文本任何部分的结果 请改为将 between, before 或 after 传递给条件。
created_at:
label: Created
type: date
conditions:
equals: true你可以传递一个 default 值,确保它用引号包裹以表示一个字符串。默认值可以设置为 now 以指定当前日期。
created_at:
label: Created
type: date
default: '2020-01-02'您可以设置 minDate 和 maxDate 以确定最小和最大可用日期范围。
created_at:
label: Date
type: date
minDate: '2001-01-23'
maxDate: '2030-10-13'您可以将自定义 SQL 作为附带支持值的字符串传递给条件。
created_at:
label: Created
type: date
conditions:
before: created_at <= :value
between: created_at >= :after AND created_at <= :before以下参数受支持。
:value:选定的日期,格式为 Y-m-d 00:00:00:valueDate: 选定的日期,格式为 Y-m-d之前: 日期格式化为 Y-m-d 00:00:00:beforeDate: 之前的日期 格式为 Y-m-d:after: 之后日期格式为 Y-m-d 00:00:00:afterDate: 之后日期,格式为 Y-m-d在 PHP 中访问时,你可以在模型中定义一个自定义的 modelScope,使用以下示例。
created_at:
label: Created
type: date
modelScope: dateFilterscopeDateFilter 方法定义,其值取自 $scope->value, $scope->before 和 $scope->after。
function scopeDateFilter($query, $scope)
{
if ($scope->condition === 'equals') {
$query->where('created_at', $scope->value);
}
elseif ($scope->condition === 'notEquals') {
$query->where('created_at', `<>`, $scope->value);
}
elseif ($scope->condition === 'between') {
$query
->where('created_at', `>=`, $scope->after)
->where('created_at', `<=`, $scope->before);
}
elseif ($scope->condition === 'after') {
$query->where('created_at', `>=`, $scope->value);
}
else {
$query->where('created_at', `<=`, $scope->value);
}
}