I think i found a bug. I use 'pt-PT' localization and is EJ2 MVC Grid.
I have this column, DateTime field in BD and ViewModel, in one of my grids:
col.Field(c => c.Inicio).Type("date").Format(new { type = "date", format = "HH:mm" }).EditType("datetimepickeredit") |
with javascript code:
function createTimePicker(args) { function writeTimePicker(args) { function readTimePicker(args) { |
If i disable the 'enableMask' property it works like it should.
If i enable it, when i try to edit a previous saved value, the value is lost. It defaults to the '00:00' value.
My goal is to use the mask function to be able to insert the time without having to go to the ':' key.
And if possible, when i click the cell, put the cursor all to the left part of the input box to start typing.
Thanks
|
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Add();
col.Field("EmployeeID").HeaderText("Employee ID").Add();
col.Field("CustomerID").HeaderText("CustomerID").Add();
col.Field("OrderDate").HeaderText("Order Date").Type("date").EditType("datetimepickeredit").Width("150").Format(new { type = "datetime", format = "HH:mm" }).Edit(new { @params = new Syncfusion.EJ2.Calendars.TimePicker { ShowClearButton = false }, create = "createTimePicker", read = "readTimePicker", write = "writeTimePicker", destroy="destroyTimePicker" }).Add();
}).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Normal); }).Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).Render()
</div>
<script>
var timeObj, timepicEle;
function createTimePicker(args) {
return document.createElement('input');
}
function writeTimePicker(args) {
timeObj = new ej.calendars.TimePicker({
format: args.column.edit.params?.format ?? 'HH:mm',
value: new Date(args.rowData[args.column.field]),
enableMask: true,
step: args.column.edit.params?.step ?? 30,
showClearButton: args.column.edit.params?.showClearButton ?? true
});
timeObj.appendTo(args.element);
}
function readTimePicker(args) {
return timeObj.value;
}
function destroyTimePicker() {
timeObj.destroy();
} |
Some problems i detected:
Query1:
You can use your sample, and just need to duplicate the grid column 'OrderDate'. Check the video i send.
Sample link: https://www.syncfusion.com/downloads/support/forum/169684/ze/Grid-CellEditTemplate-220030552.zip
Attachment: errors_2842e6b1.zip
Query2:
A mask property is to format the data you type in the correct places.
If i want the value "22:30", i only press the keys "2", "2", "3" and finally "0". And the value it will be "22:30".
BUT if i want the value "01:15", the default behaviour shouldn't be to press "0", "1", "1" and finally "5"?
Do you know what value it will be? "11:05". Did i type that? No. I think it's wrong.
Tell me which keys i should press to have "01:15" using only the numerical keypad.
If it's a mask property, i shouldn't need to control the cursor with diretional keys, to control what is hours and minutes, and worst, only when the hours are below 10!
Because my goal is to change input fields with tab key and only press numerical keypad to input hours and minutes, in several fields...