想法如下:文本输入后拦截enter 键,如果用户没有登录则调出 登录画面,如果用户已登录且已授权,则调出资料画面,但是没有实现。在chrome 内出现这个提示 Uncaught TypeError: Cannot call method 'show' of undefined,代码如下:
gg_imported = Ext.extend(Ext.grid.GridPanel, { InsertWin: new AddInfoWin(), UpdateWin: new UpdateInfoWin(), LoginWin: new LoginInfoWin(), constructor: function() { this['store'] = new Ext.data.Store({
url: 'http://10.86.116.58/WebServices/gridtest.asmx/ggconfimed',
reader: new Ext.data.XmlReader({
record: 'MyTable',
root: 'root',
totalProperty: 'totalRecords',
fields: ['GG_ID', 'MIC_GG_NUM', 'MSL_GG_NUM', 'LINE', 'PART_NUM', 'QTY', 'SHIP_TYPE', 'CS_NUM', 'CUSTOMER', 'CUST_NUM', 'GG_SO_NUM'] }) });
gg_imported.superclass.constructor.call(this, {
//autoLoad: true,
renderTo: Ext.getBody(),
closable: true,
id: '_grid1',
title: 'GG_Imported ',
//width: 800,
//height: 500,
tbar: ['-', 'MIC_GG_Query:', {
xtype: 'textfield',
id: 'mitac_pn',
width: 120,
emptyText: 'Pls Input MIC_GG_NUM',
enableKeyEvents: true,
listeners: {
specialkey: function(field, e) {
mic_gg = Ext.get('mitac_pn').dom.value;
//var _record = Ext.get('mitac_pn').dom.value;
if (e.getKey() == e.ENTER && mic_gg != '' && mic_gg != 'Pls Input MIC_GG_NUM') {
var res = '';
sta = '1';
if (name == "") {
this.LoginWin.show(); } else {
Ext.Ajax.request({
url: 'http://10.86.116.58/WebServices/gridtest.asmx/userchk',
params: { user: name, program_id: 21 },
method: 'post',
async: false,
success: function(result) {
res = result.responseText;
//alert(res);
//this.InsertWin.show(); },
failure: function() {
Ext.MessageBox.alert("Warning!!", 'system error!!');
//return 0;
}
});
}; //alert(res);
if (res == 'true') {
this.InsertWin.show();
//alert('Passed!!');
} else {
Ext.MessageBox.alert("Warning!!", "Your access was denied! Plz contract with Admin!!");
//alert("Failed!!");
};
};
}
},
scope: this } 但是在同样是.show 在query的按键的handle内就能调用
text: 'Query',
iconCls: 'query',
handler: function() {
mic_gg = Ext.get('mitac_pn').dom.value; //var _record = Ext.get('mitac_pn').dom.value;
//Ext.getCmp('_grid1').getStore().baseParams['IV_NO'] = _record;
if (mic_gg != 'Pls Input MIC_GG_NUM') {
//Ext.getCmp('_grid1').getStore().load({ params: { start: 0, limit: 50} });
var res = '';
sta = '1';
if (name == "") {
this.LoginWin.show(); } else {
Ext.Ajax.request({
url: 'http://10.86.116.58/WebServices/gridtest.asmx/userchk',
params: { user: name, program_id: 21 },
method: 'post',
async: false,
success: function(result) {
res = result.responseText;
},
failure: function() {
Ext.MessageBox.alert("Warning!!", 'system error!!');
//return 0;
}
});
if (res == 'true') {
this.InsertWin.show();
//alert('Passed!!');
} else {
Ext.MessageBox.alert("Warning!!", "Your access was denied! Plz contract with Admin!!");
//alert("Failed!!");
};
};
} else {
Ext.Msg.alert("系統提示", "請輸入 MIC_GG_NUM 進行查詢!");
};
}, scope: this
}
求大牛指点迷津!!
gg_imported = Ext.extend(Ext.grid.GridPanel, { InsertWin: new AddInfoWin(), UpdateWin: new UpdateInfoWin(), LoginWin: new LoginInfoWin(), constructor: function() { this['store'] = new Ext.data.Store({
url: 'http://10.86.116.58/WebServices/gridtest.asmx/ggconfimed',
reader: new Ext.data.XmlReader({
record: 'MyTable',
root: 'root',
totalProperty: 'totalRecords',
fields: ['GG_ID', 'MIC_GG_NUM', 'MSL_GG_NUM', 'LINE', 'PART_NUM', 'QTY', 'SHIP_TYPE', 'CS_NUM', 'CUSTOMER', 'CUST_NUM', 'GG_SO_NUM'] }) });
gg_imported.superclass.constructor.call(this, {
//autoLoad: true,
renderTo: Ext.getBody(),
closable: true,
id: '_grid1',
title: 'GG_Imported ',
//width: 800,
//height: 500,
tbar: ['-', 'MIC_GG_Query:', {
xtype: 'textfield',
id: 'mitac_pn',
width: 120,
emptyText: 'Pls Input MIC_GG_NUM',
enableKeyEvents: true,
listeners: {
specialkey: function(field, e) {
mic_gg = Ext.get('mitac_pn').dom.value;
//var _record = Ext.get('mitac_pn').dom.value;
if (e.getKey() == e.ENTER && mic_gg != '' && mic_gg != 'Pls Input MIC_GG_NUM') {
var res = '';
sta = '1';
if (name == "") {
this.LoginWin.show(); } else {
Ext.Ajax.request({
url: 'http://10.86.116.58/WebServices/gridtest.asmx/userchk',
params: { user: name, program_id: 21 },
method: 'post',
async: false,
success: function(result) {
res = result.responseText;
//alert(res);
//this.InsertWin.show(); },
failure: function() {
Ext.MessageBox.alert("Warning!!", 'system error!!');
//return 0;
}
});
}; //alert(res);
if (res == 'true') {
this.InsertWin.show();
//alert('Passed!!');
} else {
Ext.MessageBox.alert("Warning!!", "Your access was denied! Plz contract with Admin!!");
//alert("Failed!!");
};
};
}
},
scope: this } 但是在同样是.show 在query的按键的handle内就能调用
text: 'Query',
iconCls: 'query',
handler: function() {
mic_gg = Ext.get('mitac_pn').dom.value; //var _record = Ext.get('mitac_pn').dom.value;
//Ext.getCmp('_grid1').getStore().baseParams['IV_NO'] = _record;
if (mic_gg != 'Pls Input MIC_GG_NUM') {
//Ext.getCmp('_grid1').getStore().load({ params: { start: 0, limit: 50} });
var res = '';
sta = '1';
if (name == "") {
this.LoginWin.show(); } else {
Ext.Ajax.request({
url: 'http://10.86.116.58/WebServices/gridtest.asmx/userchk',
params: { user: name, program_id: 21 },
method: 'post',
async: false,
success: function(result) {
res = result.responseText;
},
failure: function() {
Ext.MessageBox.alert("Warning!!", 'system error!!');
//return 0;
}
});
if (res == 'true') {
this.InsertWin.show();
//alert('Passed!!');
} else {
Ext.MessageBox.alert("Warning!!", "Your access was denied! Plz contract with Admin!!");
//alert("Failed!!");
};
};
} else {
Ext.Msg.alert("系統提示", "請輸入 MIC_GG_NUM 進行查詢!");
};
}, scope: this
}
求大牛指点迷津!!
listeners: {
specialkey: function(field, e) {
mic_gg = Ext.get('mitac_pn').dom.value;
//var _record = Ext.get('mitac_pn').dom.value;
if (e.getKey() == e.ENTER && mic_gg != '' && mic_gg != 'Pls Input MIC_GG_NUM') {
var res = '';
sta = '1';
if (name == "") {
this.LoginWin.show();
} else {
Ext.Ajax.request({
url: 'http://10.86.116.58/WebServices/gridtest.asmx/userchk',
params: { user: name, program_id: 21 },
method: 'post',
async: false,
success: function(result) {
res = result.responseText;
//alert(res);
//this.InsertWin.show();
},
failure: function() {
Ext.MessageBox.alert("Warning!!", 'system error!!');
//return 0;
}
});
};
//alert(res);
if (res == 'true') {
_this.InsertWin.show();
//alert('Passed!!');
} else {
Ext.MessageBox.alert("Warning!!", "Your access was denied! Plz contract with Admin!!");
//alert("Failed!!");
};
};
}
},
然后登陆画面没有办法在登陆后关闭;
还有if和else在呢么可能同时执行呢?你得找到真正情况