Skip to content

Commit 8b09426

Browse files
authored
Merge pull request #4856 from syncfusion-content/910140-dev
910140: Documentaion for Time Restriction, Input Formats and Disabled…
2 parents 56e75fc + 7ef15c7 commit 8b09426

File tree

16 files changed

+223
-12
lines changed

16 files changed

+223
-12
lines changed

blazor-toc.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3326,6 +3326,7 @@
33263326
<li><a href="/blazor/mention/working-with-data">Working with Data</a></li>
33273327
<li><a href="/blazor/mention/filtering-data">Filtering Data</a></li>
33283328
<li><a href="/blazor/mention/sorting">Sorting</a></li>
3329+
<li> <a href="/blazor/mention/disabled-items">Disabled Items</a></li>
33293330
<li><a href="/blazor/mention/templates">Templates</a></li>
33303331
<li><a href="/blazor/mention/localization">Localization</a></li>
33313332
<li><a href="/blazor/mention/customization">Customization</a></li>

blazor/autocomplete/disabled-items.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ The disableItem method can be used to handle dynamic changing in disable state o
2727

2828
| Parameter | Type | Description |
2929
|------|------|------|
30-
| itemHTMLLIElement | <code>HTMLLIElement</code> | It accepts the HTML Li element of the item to be removed. |
3130
| itemValue | <code>string</code> \| <code>number</code> \| <code>boolean</code> \| <code>object</code> | It accepts the string, number, boolean and object type value of the item to be removed. |
3231
| itemIndex | <code>number</code> | It accepts the index of the item to be removed. |
3332

blazor/combobox/disabled-items.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ The disableItem method can be used to handle dynamic changing in disable state o
2727

2828
| Parameter | Type | Description |
2929
|------|------|------|
30-
| itemHTMLLIElement | <code>HTMLLIElement</code> | It accepts the HTML Li element of the item to be removed. |
3130
| itemValue | <code>string</code> \| <code>number</code> \| <code>boolean</code> \| <code>object</code> | It accepts the string, number, boolean and object type value of the item to be removed. |
3231
| itemIndex | <code>number</code> | It accepts the index of the item to be removed. |
3332

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
@using Syncfusion.Blazor.Calendars
3+
4+
<SfDatePicker TValue="DateTime?" Format="yyyy-MM-dd" InputFormats='new string[] { "dd/MM/yyyy", "MM-dd-yyyy", "yyyy/MM/dd" }' @bind-Value="@Value"></SfDatePicker>
5+
6+
7+
@code {
8+
public DateTime? Value { get; set; } = new DateTime(2022, 12, 11, 11, 30, 00);
9+
}

blazor/datepicker/date-format.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ documentation: ug
99

1010
# Date Format in Blazor DatePicker Component
1111

12-
The date format can be used to specify how the date value is displayed or entered in a `DatePicker` control
12+
## Display Format
13+
14+
The display format can be used to specify how the date value is displayed or entered in a `DatePicker` control
1315

1416
The string format of the date value specifies how the date value should be represented as a string. Different countries and regions have different conventions for representing the date value in a string format. In addition to representing the date value in different string formats, it is also possible to specify the order in which the day, month, and year values appear in the string. For example, the day/month/year format could be written as `28-12-2022` or `28.12.2022`
1517

1618
By default, the DatePicker's format is based on the culture. You can also set the own [Custom Format](https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings) or [Standard Format](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings) by using the [Format](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Calendars.SfDatePicker-1.html#Syncfusion_Blazor_Calendars_SfDatePicker_1_Format) property.
1719

18-
> Once the date format property has been defined, it will be applied consistently to all cultures, regardless of their conventions for representing the date value. In other words, the date format property serves as a standardized way of representing the date value, ensuring that it is displayed and entered consistently regardless of the culture or region in which the application is used.
20+
> Once the display format property has been defined, it will be applied consistently to all cultures, regardless of their conventions for representing the date value. In other words, the display format property serves as a standardized way of representing the date value, ensuring that it is displayed and entered consistently regardless of the culture or region in which the application is used.
1921
2022
{% highlight Razor %}
2123

@@ -24,5 +26,16 @@ By default, the DatePicker's format is based on the culture. You can also set th
2426
{% endhighlight %}
2527

2628

29+
![Date Format in Blazor DatePicker](./images/DatePicker.png)
30+
31+
## Input Formats
32+
33+
The input format can be used to specify how the date value is entered in a `DatePicker` control.
34+
35+
The string format of the date value specifies how the date should be represented as a string when entered by the user. When the user types the date in the input format, it will be automatically converted to the display format after pressing enter, tab key, or when the input loses focus. This enhances the user experience by allowing intuitive data entry through various custom input formats. You can also set your own [Custom Format](https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings) or [Standard Format](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings) by using [InputFormats](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Calendars.SfDatePicker-1.html#Syncfusion_Blazor_Calendars_SfDatePicker_1_InputFormats) property.
36+
37+
{% highlight Razor %}
38+
39+
{% include_relative code-snippet/InputFormat.razor %}
2740

28-
![Date Format in Blazor DatePicker](./images/DatePicker.png)
41+
{% endhighlight %}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
@using Syncfusion.Blazor.Calendars
3+
4+
<SfDateTimePicker TValue="DateTime?" Format="yyyy-MM-dd hh:mm:ss" InputFormats='new string[] { "dd/MM/yyyy hh:mm", "MM-dd-yyyy HH:mm", "yyyy/MM/dd hh mm tt" }' @bind-Value="@Value"></SfDateTimePicker>
5+
6+
7+
@code {
8+
public DateTime? Value { get; set; } = new DateTime(2022, 12, 11, 11, 30, 00);
9+
}

blazor/datetime-picker/date-time-format.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ documentation: ug
88
---
99
# DateTime Format in Blazor DateTimePicker Component
1010

11-
The date and time format can be used to specify how the date and time value is displayed or entered in a `DateTimePicker` control
11+
## Display Date and Time format
12+
13+
The display date and time format can be used to specify how the date and time value is displayed or entered in a `DateTimePicker` control
1214

1315
By default, the DateTimePicker's format is based on the culture. You can also set the own [Custom Format](https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings) or [Standard Format](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings) by using the [Format](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Calendars.SfDatePicker-1.html#Syncfusion_Blazor_Calendars_SfDatePicker_1_Format) property.
1416

@@ -21,4 +23,16 @@ By default, the DateTimePicker's format is based on the culture. You can also se
2123
{% endhighlight %}
2224

2325

24-
![Date Time Format in Blazor DateTimePicker](./images/DateTimePicker.png)
26+
![Date Time Format in Blazor DateTimePicker](./images/DateTimePicker.png)
27+
28+
## Input Formats
29+
30+
The input format can be used to specify how the date and time value is entered in a `DateTimePicker` control.
31+
32+
The string format of the date and time value specifies how the date and time should be represented as a string when entered by the user. When the user types the date and time in the input format, it will be automatically converted to the display format after pressing enter, tab key, or when the input loses focus. This enhances the user experience by allowing intuitive data entry through various custom input formats. You can also set your own [Custom Format](https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings) or [Standard Format](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings) by using the [InputFormats](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Calendars.SfDateTimePicker-1.html#Syncfusion_Blazor_Calendars_SfDateTimePicker_1_InputFormats) property.
33+
34+
{% highlight Razor %}
35+
36+
{% include_relative code-snippet/InputFormat.razor %}
37+
38+
{% endhighlight %}

blazor/datetime-picker/date-time-range.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ documentation: ug
99

1010
# DateTime Range in Blazor Datetime Picker Component
1111

12+
## DateTime Restriction
13+
1214
DateTimePicker provides an option to select a date and time value within a specified range by using the [Min](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Calendars.SfDateTimePicker-1.html#Syncfusion_Blazor_Calendars_SfDateTimePicker_1_Min) and [Max](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Calendars.SfDateTimePicker-1.html#Syncfusion_Blazor_Calendars_SfDateTimePicker_1_Max) properties. The Min value must always be less than the Max value.
1315

1416
The `Value` property depends on the Min/Max with respect to [StrictMode](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Calendars.SfDateTimePicker-1.html#Syncfusion_Blazor_Calendars_SfDateTimePicker_1_StrictMode) property. For more information about StrictMode, refer to the [Strict Mode](./strict-mode) section from the documentation.
@@ -47,4 +49,42 @@ When the Min and Max properties are configured and the selected datetime value i
4749

4850
![Blazor DateTimePicker displays Selected Date and Time](./images/blazor-datetimepicker-date-time-selection.png)
4951

50-
N> If the value of `Min` or `Max` properties changed through code behind, you have to update the `Value` property to set within the range.
52+
N> If the value of `Min` or `Max` properties changed through code behind, you have to update the `Value` property to set within the range.
53+
54+
## Time Restriction
55+
56+
DateTimePicker provides an option to select a time value within a specified range by using the [MinTime](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Calendars.SfDateTimePicker-1.html#Syncfusion_Blazor_Calendars_SfDateTimePicker_1_MinTime) and [MaxTime](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Calendars.SfDateTimePicker-1.html#Syncfusion_Blazor_Calendars_SfDateTimePicker_1_MaxTime) properties. The MinTime value must always be less than the MaxTime value.
57+
58+
The `Value` property depends on the MinTime/MaxTime with respect to [StrictMode](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Calendars.SfDateTimePicker-1.html#Syncfusion_Blazor_Calendars_SfDateTimePicker_1_StrictMode) property. For more information about StrictMode, refer to the [Strict Mode](./strict-mode) section from the documentation.
59+
60+
The following code allows selecting a date within the range from 10:00 AM to 8:30 PM of each day.
61+
62+
```cshtml
63+
@using Syncfusion.Blazor.Calendars
64+
65+
<SfDateTimePicker TValue="DateTime?" MinTime='@MinTime' MaxTime='@MaxTime' Value='@DateTimeValue'></SfDateTimePicker>
66+
67+
@code {
68+
public DateTime DateTimeValue { get; set; } = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 9, 11, 0, 0);
69+
public DateTime MinTime { get; set; } = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 7, 10, 0, 0);
70+
public DateTime MaxTime { get; set; } = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 27, 20, 30, 0);
71+
}
72+
```
73+
74+
![Time Selection in Blazor DateTimePicker](./images/blazor-datetimepicker-time-selection.png)
75+
76+
When the MinTime and MaxTime properties are configured and the selected time value is out-of-range or invalid, then the model value will be set to `out of range` time value or `null` respectively with highlighted `error` class to indicate the time is out of range or invalid.
77+
78+
```cshtml
79+
@using Syncfusion.Blazor.Calendars
80+
81+
<SfDateTimePicker TValue="DateTime?" MinTime='@MinTime' MaxTime='@MaxTime' Value='@DateTimeValue'></SfDateTimePicker>
82+
83+
@code {
84+
public DateTime DateTimeValue { get; set; } = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 9, 11, 0, 0);
85+
public DateTime MinTime { get; set; } = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 7, 10, 0, 0);
86+
public DateTime MaxTime { get; set; } = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 27, 20, 30, 0);
87+
}
88+
```
89+
90+
![Blazor DateTimePicker displays Time Selection](./images/blazor-datetimepicker-time-validation.png)
18 KB
Loading
4.94 KB
Loading

0 commit comments

Comments
 (0)