- Home
- Forum
- ASP.NET Core - EJ 2
- How to set monday as a first day of the week in a datepicker?
How to set monday as a first day of the week in a datepicker?
Hello,
Is it possible to set monday as a first day of the week in a datepicker in a grid?
I have alredy changed the localization for calendar like this:
function loadCultureFiles() {
var files = ['ca-gregorian.json', 'numbers.json', 'timeZoneNames.json'];
var loader = ej.base.loadCldr;
var loadCulture = function () {
var val, ajax;
ajax = new ej.base.Ajax('@Url.Content("~/scripts/de/")' + files[prop], 'GET', false);
ajax.onSuccess = function (value) {
val = value;
};
ajax.send();
loader(JSON.parse(val));
};
for (var prop = 0; prop < files.length; prop++) {
loadCulture();
}
}
loadCultureFiles('de');
ej.base.setCulture('de');
var files = ['ca-gregorian.json', 'numbers.json', 'timeZoneNames.json'];
var loader = ej.base.loadCldr;
var loadCulture = function () {
var val, ajax;
ajax = new ej.base.Ajax('@Url.Content("~/scripts/de/")' + files[prop], 'GET', false);
ajax.onSuccess = function (value) {
val = value;
};
ajax.send();
loader(JSON.parse(val));
};
for (var prop = 0; prop < files.length; prop++) {
loadCulture();
}
}
loadCultureFiles('de');
ej.base.setCulture('de');
It works fine and the calendar have now in german , but 'Sunday' is still the first day of a week in a datepicker. How can i change it to 'Monday'
Code for the field in a grid:
<e-grid-column field="Geburtsdatum" format="dd.MM.yyyy" allowResizing="false" Width="150" editType="datepickeredit" headerText="Geburtsdatum"></e-grid-column>
SIGN IN To post a reply.
5 Replies
1 reply marked as answer
AG
Ajith Govarthan
Syncfusion Team
August 17, 2020 12:30 PM UTC
Hi Alexander,
Thanks for contacting Syncfusion support.
By default first day of week will be Sunday, so to change the behavior we suggest you to use the FirstDayOfWeek property of EJ2DatePicker.
In this the value ranges from 0 to 6 which represents the index of days in a week. In EJ2 Grid component you can use the edit property of the column to use the FirstDayOfWeek property for Datepicker component.
For your convenience we have attached the API link and code example so please refer them for your reference.
|
Index.chstml
@{
var editParams = new { @params = new { firstDayOfWeek= 1 } };
}
<ejs-grid id="Grid" allowPaging="true" load="onLoad" created="onCreated" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel","Search" })">
<e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true"></e-grid-editSettings>
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="120"></e-grid-column>
<e-grid-column field="EmployeeID" headerText="Employee Name" width="150"></e-grid-column>
<e-grid-column field="ShipCity" headerText="Ship City" width="170"></e-grid-column>
<e-grid-column field="OrderDate" headerText="Order Date" format="yMd" type="date" editType="datepickeredit" edit=editParams width="120"></e-grid-column>
<e-grid-column field="ShipCountry" headerText="Ship Country" width="150"></e-grid-column>
</e-grid-columns>
</ejs-grid> |
UG-Link: https://ej2.syncfusion.com/aspnetcore/documentation/grid/edit/#cell-edit-type-and-its-params
Please get back to us if you need further assistance.
Regards,
Ajith
Marked as answer
AL
alexander.sirotkin
August 17, 2020 01:33 PM UTC
Thank you,
@{
var editParams = new { @params = new { firstDayOfWeek= 1 } };
}return an error in my code
but
Edit="@(new { @params = new { firstDayOfWeek = 1 }})"
worked very well :)
AG
Ajith Govarthan
Syncfusion Team
August 19, 2020 01:51 PM UTC
Hi Alexander,
Thanks for the update.
We are happy to hear that your issue has been resolved.
Please get back to us if you need further assistance.
Regards,
Ajith G.
PE
Petr
May 23, 2021 10:27 AM UTC
Hello,
I'm sorry to hijack this thread - is it possible to set this globally?
For example by changing/adding additional parameter to culture file, e.g. 'ca-gregorian.json'?
I find it really annoying to set this up for each and every datepicker component I use.
Thank you,
Petr
AG
Ajith Govarthan
Syncfusion Team
May 24, 2021 12:14 PM UTC
Hi Petr,
Thanks for the update.
Query: For example by changing/adding additional parameter to culture file, e.g. 'ca-gregorian.json'? I find it really annoying to set this up for each and every datepicker component I use.
Based on your query we suspect that you want to add culture parameters globally for all your date picker component. So, before we proceed to your query, please share the below details to validate further on your requirement.
- Have you used the DatePicker component inside the Grid component?
- Please share the code examples of your application.
- Please share the screenshot or video demonstration of your requirement.
- Share the Syncfusion package version.
Regards,
Ajith G.
SIGN IN To post a reply.
- 5 Replies
- 3 Participants
- Marked answer
-
AL alexander.sirotkin
- Aug 14, 2020 12:20 PM UTC
- May 24, 2021 12:14 PM UTC