First, I m going to be submitting a couple of different questions that relate to the code snippet posted here. So, if you see other questions and think "hey, that s a duplicate, I ve seen that code" it really isn t. I want to be sure to credit each answerer for the distinctly different questions. Here s one: I have the following jqgrid, and I m trying to change the masking from "__" to "00" when the user only enters the first half of the field. The method gets called, the value changed, but it still displays the old value. I m using jqgrid version 4.2. Grid:
WorkSchedule.prototype.init = function() {
var self = this;
self.jqgridParms = {
datatype: "local",
height: auto ,
width: 700,
colNames: ["Week", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Total"],
colModel: [// very much dummy stuff here.
{name: "Week", index: "Week", width: 50, editable: false },
{ name: "Sun", index: "Sun", width: 85, editable: true, edittype: "text", editoptions: { size: 20, maxlength: 30,
dataInit: function(elem) {
$(elem).mask("99:99");
}
}, align: "center", formatter: timeEntryFormat, editrules: { custom: true, custom_func: validHourEntry }
},
{ name: "Mon", index: "Mon", width: 85, editable: true, edittype: "text", editoptions: { size: 20, maxlength: 30,
dataInit: function(elem) {
$(elem).mask("99:99");
}
}, align: "center", formatter: timeEntryFormat, editrules: { custom: true, custom_func: validHourEntry }
},
{ name: "Tues", index: "Tues", width: 85, editable: true, edittype: "text", editoptions: { size: 20, maxlength: 30,
dataInit: function(elem) {
$(elem).mask("99:99");
}
},
align: "center", formatter: timeEntryFormat, editrules: { custom: true, custom_func: validHourEntry }
},
{ name: "Wed", index: "Wed", width: 85, editable: true, edittype: "text", editoptions: { size: 20, maxlength: 30,
dataInit: function(elem) {
$(elem).mask("99:99");
}
},
align: "center", formatter: timeEntryFormat, editrules: { custom: true, custom_func: validHourEntry }
},
{ name: "Thurs", index: "Thurs", width: 85, editable: true, edittype: "text", editoptions: { size: 20, maxlength: 30,
dataInit: function(elem) {
$(elem).mask("99:99");
}
},
align: "center", formatter: timeEntryFormat, editrules: { custom: true, custom_func: validHourEntry }
},
{ name: "Fri", index: "Fri", width: 85, editable: true, edittype: "text", editoptions: { size: 20, maxlength: 30,
dataInit: function(elem) {
$(elem).mask("99:99");
}
},
align: "center", formatter: timeEntryFormat, editrules: { custom: true, custom_func: validHourEntry }
},
{ name: "Sat", index: "Sat", width: 85, editable: true, edittype: "text", editoptions: { size: 20, maxlength: 30,
dataInit: function(elem) {
$(elem).mask("99:99");
}
},
align: "center", formatter: timeEntryFormat, editrules: { custom: true, custom_func: validHourEntry }
},
{ name: "WeekTotal", index: "WeekTotal", width: 55, editable: true, align: "center" }
],
multiselect: false,
caption: "Manage Work Schedule",
rowNum: 10,
cellEdit: true,
gridComplete: function() {
calculateTotal();
},
beforeSaveCell: function(rowid,cellname,value,iRow,iCol) {
formatFromMask(rowid, cellname, value, iRow, iCol);
},
afterSaveCell: function() {
calculateTotal();
},
cellsubmit: "clientArray"
}
}
function formatFromMask(rowid, cellname, value, iRow, iCol) {
if (typeof value !== "undefined") {
value = value.replace(/_/g, "0");
return value;
}
}