I want to have input mask for the child grid column to enter the time value in format like HH:mm, and maybe with placeholders like __:__.
Is there some example?
Thanks!
Bernard.
Hi Rajapandiyan!
My requirement is just simple. The grid column is in string format and I just want to type input string in hour format
like HH:mm but maybe with placeholders __:__ so I can only type numbers over the _.
I don't need filtering, sorting and grouping and the grid is saving string format in the database.
Is it clear enough?
Regards,
Bernard.
|
@{
var valueAccessor = "valueAccessorFn";
}
<ejs-grid id="Grid" load="load">
----
<e-grid-column field="EntryTime" headerText="Entry Time" textAlign="Right" edit="@(new {create = "create", read = "read", destroy = "destroy", write = "write"})" valueAccessor="valueAccessor" width="120"></e-grid-column>
</ejs-grid>
<script>
---
var elem;
var maskObj;
function create(args) {
// create a input element
elem = document.createElement("input");
return elem;
}
function read(args){
// renturn the value which will be bound to the Grid
return maskObj.value;
}
function destroy(args) {
// destroy the component
maskObj.destroy();
}
function write(args) {
// render the maskedtexbox control
maskObj = new ej.inputs.MaskedTextBox({
// sets mask format to the MaskedTextBox
mask: '00:00',
placeholder: 'Time 24 format (ex: 10:00, 20:00)',
// bind the cell value
value: args.rowData[args.column.field],
floatLabelType: 'Always'
});
maskObj.appendTo(elem);
}
</script>
|
|
<script>
function valueAccessorFn(field, data, column){
var value = data[field];
return value.slice(0, 2) + ":" + value.slice(2); // return the customized value
}
</script>
|
|
<script>
function load(args) {
this.columns[2].validationRules = { required: true, regex: [customFn, 'Enter valid time'] };
}
function customFn(args) {
// validate the value based on your condition and return the boolean value
return args.value.match(/^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/);
};
</script>
|
Hi Rajapandiyan,
and thanks for the given example. It's working great.
Thumbs up! :)
Regards,
Bernard.