Skip to content

Commit d52a727

Browse files
authored
Placeholders for the Date*Pickers (#521)
* chore(dateinput): placeholder docs * chore(datepicker): placeholder docs * chore(daterangepicker): placeholder docs * chore(datetimepicker): placeholder docs * chore(timepicker): placeholder docs * chore(placeholders): format placeholders
1 parent b036610 commit d52a727

File tree

8 files changed

+86
-4
lines changed

8 files changed

+86
-4
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#format-placeholder
2+
3+
## Format Placeholder
4+
5+
The `FormatPlaceholder` parameter allows you to set custom strings as placeholders for each DateTime segment and is available for the following Telerik UI for Blazor components:
6+
7+
* DateInput
8+
* DatePicker
9+
* DateTimePicker
10+
* DateRangePicker
11+
* TimePicker
12+
13+
To set up the `FormatPlaceholder`, you should use the `<*Component*FormatPlaceholder>` nested tag. It allows you to set format placeholders by using the following parameters:
14+
15+
* `Day`
16+
* `Month`
17+
* `Year`
18+
* `Hour`
19+
* `Minute`
20+
* `Second`
21+
* `Weekday`
22+
23+
By default the value for all parameters would be `null`, the full format specifier for would be applied.
24+
25+
>caption Provide a custom string to the day, month, and year segments
26+
27+
````CSHTML
28+
@* Provide custom rendering of the day, month, and year segments *@
29+
30+
<TelerikDatePicker @bind-Value="@DateValue">
31+
<DatePickerFormatPlaceholder Day="Day"
32+
Month="Month"
33+
Year="YEAR">
34+
</DatePickerFormatPlaceholder>
35+
</TelerikDatePicker>
36+
37+
@code {
38+
public DateTime? DateValue { get; set; }
39+
}
40+
````
41+
42+
#end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#format-placeholder
2+
3+
### Format Placeholder
4+
5+
The `FormatPlaceholder` parameter allows you to set custom strings as placeholders for each DateTime segment and is available for the following Telerik UI for Blazor components:
6+
7+
* DateInput
8+
* DatePicker
9+
* DateTimePicker
10+
* DateRangePicker
11+
* TimePicker
12+
13+
To set up the `FormatPlaceholder`, you should use the `<*Component*FormatPlaceholder>` nested tag. It allows you to set format placeholders by using the following parameters:
14+
15+
* `Day`
16+
* `Month`
17+
* `Year`
18+
* `Hour`
19+
* `Minute`
20+
* `Second`
21+
* `Weekday`
22+
23+
By default the value for all parameters would be `null`, the full format specifier for would be applied.
24+
25+
#end

components/chart/types/column.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ The <a href="https://www.telerik.com/blazor-ui/column-chart" target="_blank">Bla
1818

1919
@[template](/_contentTemplates/chart/link-to-basics.md#understand-basics-and-databinding-first)
2020

21+
@[template](/_contentTemplates/date-inputs/format-placeholders.md#format-placeholder)
22+
2123
#### To create a column chart:
2224

2325
1. add a `ChartSeries` to the `ChartSeriesItems` collection

components/dateinput/overview.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ The date input provides the following features:
5656

5757
* `TabIndex` - maps to the `tabindex` attribute of the HTML element. You can use it to customize the order in which the inputs in your form focus with the `Tab` key.
5858

59+
* `Placeholder` - `string` - maps to the `placeholder` attribute of the HTML element. The `Placeholder` will appear if the component is bound to nullable DateTime object - `DateTime?`, but will not be rendered if the component is bound to the default value of a non-nullable DateTime object.
60+
5961
* Validation - see the [Input Validation]({%slug common-features/input-validation%}) article.
6062

63+
@[template](/_contentTemplates/date-inputs/format-placeholders.md#format-placeholder)
64+
6165
## DateTime and Nullable DateTime
6266

6367
The behavior of the component will depend on the type of field it is bound to, and this can result in different user experience and values that it will output:

components/datepicker/overview.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ The Blazor Date Picker component exposes the following features:
6767

6868
* `TabIndex` - maps to the `tabindex` attribute of the HTML element. You can use it to customize the order in which the inputs in your form focus with the `Tab` key.
6969

70+
* `Placeholder` - `string` - maps to the `placeholder` attribute of the HTML element. The `Placeholder` will appear if the component is bound to **nullable** DateTime object - `DateTime?`, but will not be rendered if the component is bound to the default value of a non-nullable DateTime object.
71+
7072
* Validation - see the [Input Validation]({%slug common-features/input-validation%}) article.
7173

7274
The date picker is, essentially, a [date input]({%slug components/dateinput/overview%}) and a [calendar]({%slug components/calendar/overview%}) and the properties it exposes are mapped to the corresponding properties of these two components. You can read more about their behavior in the respective components' documentation.
7375

74-
76+
@[template](/_contentTemplates/date-inputs/format-placeholders.md#format-placeholder)
7577

7678
## See Also
7779

components/daterangepicker/overview.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,16 @@ The Blazor Date Range Picker component exposes the following features:
6464

6565
* `TabIndex` - maps to the `tabindex` attribute of both `input` HTML elements in the component and them both will have the same `tabindex`. You can use it to customize the order in which the inputs in your form focus with the `Tab` key.
6666

67+
* `Placeholder` - `string` - maps to the `placeholder` attribute of the HTML element. The `Placeholder` will appear if the component is bound to **nullable** DateTime object - `DateTime?`, but will not be rendered if the component is bound to the default value of a non-nullable DateTime object.
68+
6769
* Validation - see the [Input Validation]({%slug common-features/input-validation%}) article.
6870
* To restrict the user from writing dates in the input so that the end is after the start, you must implement a custom data annotation attribute (you can find an example in the article linked above). The DateRangePicker component does not do this out-of-the-box in order to provide smooth user experience - the code cannot know what the user intent is and they might fix the range if they are given the chance, so correcting the input immediately may prevent them from using it comfortably. The component can fully control the user experience in the popup calendar and it ensures there that the range values are valid (start is before the end). If the user chooses an end date before the start, this date becomes the new start and they can choose the end again.
6971

7072
* [Events]({%slug daterangepicker-events %}) - a set of events that let you respond to the user actions with the component, and also to extract the data from it.
7173

7274
The date range picker is, essentially, a [date input]({%slug components/dateinput/overview%}) and a [calendar]({%slug components/calendar/overview%}) and the properties it exposes are mapped to the corresponding properties of these two components. You can read more about their behavior in the respective components' documentation.
7375

74-
76+
@[template](/_contentTemplates/date-inputs/format-placeholders.md#format-placeholder)
7577

7678
## See Also
7779

components/datetimepicker/overview.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,16 @@ The DateTimePicker component exposes the following features:
7070

7171
* `TabIndex` - maps to the `tabindex` attribute of the HTML element. You can use it to customize the order in which the inputs in your form focus with the `Tab` key.
7272

73-
* Validation - see the [Input Validation]({%slug common-features/input-validation%}) article.
74-
73+
* `Placeholder` - `string` - maps to the `placeholder` attribute of the HTML element. The `Placeholder` will appear if the component is bound to **nullable** DateTime object - `DateTime?`, but will not be rendered if the component is bound to the default value of a non-nullable DateTime object.
7574

75+
* Validation - see the [Input Validation]({%slug common-features/input-validation%}) article.
7676

7777
When using the dropdown to edit dates, you must click the "Set" button to commit the date. It is located in the Time portion of the dropdown (you will be navigated to it automatically upon selecting a date). Clicking "Cancel", or outside of the dropdown without clicking "Set", will revert the time to the original value. You can also commit a date by clicking the "NOW" button which will choose the current time.
7878

7979
The time format specifiers in the `Format` control the tumblers available in the dropdown. For example, the `HH` specifier will result in a hour selector in a 24 hour format. If you also add the `tt` specifier, you will also get the AM/PM tumbler, but the 24 hour format will still be used. This means that you can also add several tumblers for the same time portion if the format string repeats them.
8080

81+
@[template](/_contentTemplates/date-inputs/format-placeholders.md#format-placeholder)
82+
8183

8284
## See Also
8385

components/timepicker/overview.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ The Time Picker component exposes the following features:
7070
* `Width` - Defines the width of the TimePicker.
7171

7272
* `TabIndex` - maps to the `tabindex` attribute of the HTML element. You can use it to customize the order in which the inputs in your form focus with the `Tab` key.
73+
*
74+
* `Placeholder` - `string` - maps to the `placeholder` attribute of the HTML element. The `Placeholder` will appear if the component is bound to **nullable** DateTime object - `DateTime?`, but will not be rendered if the component is bound to the default value of a non-nullable DateTime object.
7375

7476
* Validation - see the [Input Validation]({%slug common-features/input-validation%}) article.
7577

@@ -81,6 +83,7 @@ The time format specifiers in the `Format` control the tumblers available in the
8183

8284
The Time Picker component supports `DateTime`, `DateTime?`, `DateTimeOffset` and `DateTimeOffset?` types.
8385

86+
@[template](/_contentTemplates/date-inputs/format-placeholders.md#format-placeholder)
8487

8588
## See Also
8689

0 commit comments

Comments
 (0)