ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: omerix on February 04, 2025, 11:32:07 pm
-
Hello,
When I paste data from Excel to the grid, only "yyyy-mm-dd" is accepted as the date format.
Is there a solution other than making datetype="string"?
Options:
fmtDate: 'dd/mm/yyyy',
fmtDateEdit: 'dd/mm/yyyy',
fmtDateFilter: 'dd/mm/yyyy'
colModel
{
title: 'Date Column',
dataIndx: 'date1',
dataType: 'date',
halign: 'center',
desc: 'Process Date',
hidden: false,
editable: true,
format: 'dd/mm/yyyy',
editor: { type: 'textbox', init: dateU },
filter: { crules: [{ condition: 'between' }], menuIcon: false }
}
dateU function
function dateU(ui) {
ui.$cell.find("input")
.datepicker({
changeMonth: true,
changeYear: true,
dateFormat: pq.excelToJui(ui.column.format),
showAnim: '',
onSelect: function () {
this.firstOpen = true;
},
beforeShow: function (input, inst) {
setTimeout(function () {
$('.ui-datepicker').css('z-index', 999999999999);
});
},
onClose: function () {
this.focus();
}
});
}
function dateB(ui) {
ui.$cell.find("input")
.bootstrapDatepicker({
format: ui.column.format,
})
.on('changeDate', function (e) {
$(this).focus();
$(this).bootstrapDatepicker('hide');
})
}
function date(ui) {
ui.$cell.find("input")
.attr("type", "date")
.on("focus", function () {
this.showPicker?.();
})
.click();
}
-
Sample:
-
It's because of the validation for ISO formatted dates in those columns.
{ type: 'regexp', value: '^[0-9]{4}-[0-9]{2}-[0-9]{2}$', msg: 'Not in yyyy-mm-dd format' }
Also either dates in ISO format or mm/dd/yyyy are accepted as valid dates in dataType: 'date' columns.
You can intercept the other formatted date values in beforePaste event so as to convert them to ISO format before pasting them to cells.
https://paramquery.com/pro/api#event-beforePaste
-
I will try with "beforePaste". Thank you.