标题: Grid模板列编辑录入,回车自动定位至下一行录入,grid翻页... [打印本页] 作者: beingtop 时间: 2013-7-11 17:01 标题: Grid模板列编辑录入,回车自动定位至下一行录入,grid翻页... Grid模板列编辑录入(asp.net TextBox),回车自动定位至下一行录入,grid翻页后,自动换行功能失效。
请三石兄和各位,帮忙一下,谢谢!
前端脚本:
<script type="text/javascript">
var gridClientID = '<%= Grid1.ClientID %>';
var lblplanners='<%=lblplanners.ClientID %>';//保存json字符串
function registerSelectEvent() {
var grid = X(gridClientID);
// 防止重复注册客户端事件
if (grid.el.getAttribute('data-event-click-registered')) {
return;
}
grid.el.set({ 'data-event-click-registered': true });
grid.el.select('.x-grid-tpl input').on('click', function (evt, el) {
el.select();
});
}
function registerEnterEvent() {
var grid = X(gridClientID);
// 防止重复注册客户端事件
if (grid.el.getAttribute('data-event-keydown-registered')) {
return;
}
grid.el.set({ 'data-event-keydown-registered': true });
grid.el.select('.x-grid-tpl input').on("keydown", function (evt, el) {
if (evt.getKey() == evt.ENTER) {
var currRow = Ext.get(el).parent('.x-grid3-row');
var plannerid = currRow.query('.x-grid-tpl input')[0].value;
var currRowIndex = currRow.parent().query('>div').indexOf(currRow.dom);
//__doPostBack(gridClientID, 'AutoSave$' + currRowIndex);
var plannerjsonstr = Ext.getCmp(lblplanners).x_state.Text;
var jsonobj = $.parseJSON(plannerjsonstr);//jquery 将json字符串转json对象
var found = 0;
for (var i in jsonobj) {
if (i == plannerid) {
currRow.query('input.showplannername')[0].value = jsonobj[i];//更加录入的工号显示姓名
found = 1;
break;
}
}
if (!found) {
currRow.query('input.showplannername')[0].value = "工号有误";
}
//跳至下一行
var nextRow = Ext.get(el).parent('.x-grid3-row').next();
if (nextRow) {
nextRow.query('.x-grid-tpl input')[0].select();
}