Jqgrid库脚本中对于b(":input:visible", a.w)[0]的Jqgrid验证例程
jqgrid validation routine errors in jqgrid library script for b(":input:visible", a.w)[0] is undefined
我使用一个自定义函数来验证我的jqgrid。用户希望以Hour:Minute
格式输入一天的工作小时数(例如,7:30,8:00)。验证规则需要在工作日超过20小时1分钟时返回false。验证函数的工作方式是标记错误,但是firebug显示第二个错误:b(":input:visible", a.w)[0] is undefined, and points to line 379 in the library (version 4.1.2)
。
感谢帮助!
下面是网格和自定义验证: 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 validHourEntry(value, colname) {
var editSuccess = true;
var errorMsg = "";
if (typeof value === "undefined") {
editSuccess = false;
errorMsg = colname + " entry is required";
}
else if (value.length == 0) {
editSuccess = false;
errorMsg = colname + " entry is required";
}
else {
value = value.replace(/_/g, "0");
var hourMinSplit = value.lastIndexOf(":");
var hours = value.substring(0, hourMinSplit);
var mins = value.substring(hourMinSplit + 1, value.length);
if (isNaN(hours)) {
editSuccess = false;
errorMsg = "The value for hours must be numeric";
}
else if (isNaN(mins)) {
editSuccess = false;
errorMsg = "The value for minutes must be numeric";
}
else if (Number(hours) * 60 + Number(mins) > 1200) {
editSuccess = false;
errorMsg = "Work day entry must not exceed 20 hours and 00 minutes";
}
}
return [editSuccess, errorMsg];
}
function createWorkScheduleData(rowID) {
if (rowID == 0) {
return [ //goofy dummy data so I can test.
{Week: "Week 1", Sun: "00:00", Mon: "00:00", Tues: "00:00", Wed: "00:00", Thurs: "00:00", Fri: "00:00", Sat: "00:00" },
{ Week: "Week 2", Sun: "00:00", Mon: "00:00", Tues: "00:00", Wed: "00:00", Thurs: "00:00", Fri: "00:00", Sat: "00:00"}];
}
else if (rowID == 1) {
return [{ Week: "Week 1", Sun: "00:00", Mon: "08:00", Tues: "08:00", Wed: "08:00", Thurs: "08:00", Fri: "08:00", Sat: "00:00" },
{
Week: "Week 2", Sun: "00:00", Mon: "08:00", Tues: "08:00", Wed: "08:00", Thurs: "08:00", Fri: "08:00", Sat: "00:00"
}
];
}
else if (rowID == 2) {
return [{ Week: "Week 1", Sun: "00:00", Mon: "04:00", Tues: "04:00", Wed: "04:00", Thurs: "04:00", Fri: "04:00", Sat: "00:00" },
{
Week: "Week 2", Sun: "00:00", Mon: "04:00", Tues: "04:00", Wed: "04:00", Thurs: "04:00", Fri: "04:00", Sat: "00:00"
}
];
}
else if (rowID == 3) {
return [{ Week: "Week 1", Sun: "00:00", Mon: "07:30", Tues: "07:30", Wed: "07:30", Thurs: "07:30", Fri: "07:30", Sat: "00:00" },
{
Week: "Week 2", Sun: "00:00", Mon: "07:30", Tues: "07:30", Wed: "07:30", Thurs: "07:30", Fri: "07:30", Sat: "00:00"
}
];
}
}
这是Firebug的问题,而不是jqgrid的问题。我把这个贴出来,以防其他人也有同样的行为。我关闭了Firebug,我的验证像预期的那样工作。它也适用于chrome和IE没有任何javascript错误。懊恼的我没有想过尝试之前张贴的问题,但高兴的是,这不是一个真正的问题。
相关文章:
- 铬:“;未捕获的语法错误:意外的标记:"
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- jqGrid树网格问题
- JS表单提交"无法使用Chrome数据保护程序加载此页面.尝试重新加载页面.调试信息:POST CISmtuK
- 检测电话窃听,即:<a href="电话:xxx">在UIWebview上
- Intercept the cellSubmit jqGrid
- 使用“+="操作人员
- //而不是在src=“”上使用http://"属性
- "未捕获的语法错误:意外的标记}"
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- "实例范围”;TypeScript类的getter/setter
- Javascript复选框函数:;缺少:在属性id之后"
- "“;变量未引用正确的对象
- "日期“;AJAX请求返回的类型值未定义
- 得到"TypeError:无法读取属性'filename'未定义的“;调用“npm start
- Soundcloud api"未捕获的类型错误:无法读取属性'uri'“未定义”;
- "工具提示"jQuery插件坏了
- 如何在jqGrid中隐藏和显示自定义按钮通过使用"reccount”;
- Jqgrid编辑类型:"选择“;事件
- "JqGrid不是一个函数“;在网格加载并工作之后