I'm trying to set a default value for a datepicker field so that when a new row is created it autofills with the default. I've tried a couple of things, but the date field with the datepicker is always blank when a new record is created.
This is the addrow button:
{ type: 'button', icon: 'ui-icon-plus', label: 'Add Inject', listener:
{ "click": function (evt, ui) {
var rowData = { griddate: "3/10/15" };
$grid.pqGrid("addRow", { rowData: rowData, rowIndxPage: 0 });
$grid.pqGrid("setSelection", { rowIndxPage: 0 });
$grid.pqGrid("editFirstCellInRow", { rowIndxPage: 0 });
}
}
},
This is the colmodel definition:
{ title: "Date", minWidth: 30, width: 75, dataIndx: "griddate", dataType: 'date',
editor: {
type: 'textbox',
init: dateEditor
},
render: function (ui) {
//return "hello";
var cellData = ui.cellData;
if (cellData) {
return $.datepicker.formatDate('m-d-y', new Date(cellData));
}
else {
return "";
}
},
validations: [
{ type: 'regexp', value: '^([0]?[1-9]|[1][0-2])[./-]([0]?[1-9]|[1|2][0-9]|[3][0|1])[./-]([0-9]{4}|[0-9]{2})$', msg: 'Not in m/d/yy format' },
]
},