javascript - Jqgrid在使用编辑规则时保持关注当前单元格

标签 javascript asp.net jqgrid

首先,我将提交几个与此处发布的代码片段相关的不同问题。因此,如果您看到其他问题并认为“嘿,这是重复的,我已经看过该代码”,但事实并非如此。我想确保将每个回答者归功于截然不同的问题。 这是一个:我有以下 jqgrid,当用户只输入字段的前半部分时,我试图将掩码从“__”更改为“00”。该方法被调用,值已更改,但它仍显示旧值。我正在使用 jqgrid 4.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 formatFromMask(rowid, cellname, value, iRow, iCol) {
            if (typeof value !== "undefined") {
                value = value.replace(/_/g, "0");
return value;
            }
        }

最佳答案

好的,我找到了简单的答案,即将掩码设置为“00:00”。它提出了一个单独的问题,但在这里解决了问题。

关于javascript - Jqgrid在使用编辑规则时保持关注当前单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8185921/

相关文章:

javascript - Microsoft Stack 中的 D3 示例

javascript - 居中对齐两个div与右边的图像

javascript - jqgrid,在编辑表单中填充值的按钮?

jquery - jqGrid:用双击代替单击进入单元格编辑模式

javascript - 如何解决平板电脑上的 col-md 无法正确显示的问题

javascript - 我可以在不更新页面的情况下更改 URL 吗?

html - 如果使用 onclick,则不会调用 OnServerClick 事件处理程序

ASP.NET 路由目录请求

asp.net - Azure 应用服务 - 免费套餐 - Cpu 时间(短)

javascript - 通过jqgrid在MVC中调用Controller的Action