date - 使用日期值进行筛选,并采用 equals、between、before 和 after 条件逻辑。
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 作为 condition 传入。若要查找包含文本任意部分的结果请改为将 between, before 或 after 传入 conditions。
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);
}
}