PDA

View Full Version : error in showing message box.



mond
25 Nov 2010, 2:34 AM
i set a custom max limit validation in textfield listeners and the data is coming from the database.
when the textfield hit the max limit the msgbox will appear but
the problem is the msgbox is showing but it closes automatically in seconds without triggers the ok button.


the messagebox is doing right when I hard code input data in the textfield.

hope to your reply.

Condor
25 Nov 2010, 6:56 AM
I don't understand the question...

Maybe it helps when you post your code.

mond
25 Nov 2010, 4:22 PM
ok here's the code:

new Ext.form.TextField({
//fieldLabel : 'Customer to be Visited',
allowBlank : false,
name : 'ACCTNAME',
id : 'ACCTNAME',
enableKeyEvents : true,
tabIndex:5,
width : 260,
listeners : {
'focus' : function(v){
if(v.getValue().length <= 65){
Ext.get('char-counter').update(defaultCount - v.getValue().length);
}

if(v.getValue().length == 65){
Ext.get('char-counter').update('0');
}
},
'keyup' : function(v){
if((v.getValue().length) > 65){
Ext.MessageBox.show({
msg : 'Character limit has been reached.',
width : 400,
buttons : Ext.MessageBox.OK,
fn : function(btn){
Ext.getCmp('ACCTNAME').setValue((v.getValue()).substr(0, 65));
}
});
}else{

if(v.getValue().length == 65){
Ext.get('char-counter').update('0');
}else{
Ext.get('char-counter').update(defaultCount - (v.getValue()).length);
}
}
}
}
})

the json encoded:

$data[] = array(
'ACCTNO'=>trim($row->ACCTNO),
'BRANCHCODE'=>trim($row->BRANCHCODE),
'ACCTNAME'=>'['.trim($row->ACCTNO).']'.trim($row->ACCTNAME),
);

Condor
26 Nov 2010, 12:53 AM
Isn't such a popup really intrusive?

Wouldn't it be easier to use

maxLength: 65
optionally combined with:

autoCreate: Ext.apply({maxlength: '65'}, Ext.form.TextField.prototype.defaultAutoCreate)

mond
26 Nov 2010, 1:50 AM
thank really much appreciated.

mond
26 Nov 2010, 1:53 AM
thanks condor! it works even withouth popup.

and would you mind i have another problem in popup.

it happens when i trigger the show button and the ajax request is on.

during submitting a request the popup closes automatically.

i suspect it has an issue in ajax json encode.


here's the code.


function showList(){
var processingBox = Ext.MessageBox.show({
msg : 'Processing Request...',
width : 250,
wait : true,
waitConfig : {interval:200}
});

Ext.Ajax.on('beforerequest',function(conn,o,result){
})

Ext.Ajax.on('requestcomplete',function(conn,o,result){
processingBox.hide();
})

Ext.Ajax.on('requestexception',function(conn,o,result){
processingBox.hide();
});
Ext.Ajax.request({
url : 'scripts/ajax/employeeIT.php',
method : 'POST',
params : {
_method : 'employeeSearch',
_class : 'employeeIT',
empName : Ext.get('empName').getValue().toUpperCase(),
},
callback : function(options,success,result){
var response = Ext.util.JSON.decode(result.responseText);
//console.log(response.data);

if(response.success){
var store3 = new Ext.data.Store({
proxy : new Ext.ux.data.PagingMemoryProxy(response.data),
reader : new Ext.data.ArrayReader({
fields : [
{name: 'ACCTNO'},
{name: 'BRANCHCODE'},
{name: 'ACCTNAME'},
]
})
});
store3.loadData(response.data);
store3.load({params:{start:0, limit:10}});
buildDataGrid(store3)
}else{
Ext.MessageBox.show({
title : 'TIMS',
msg : response.errors.reason,
buttons : Ext.MessageBox.OK,
icon : Ext.MessageBox.WARNING,
animEl : document.body
});
}
}
})
}

function buildDataGrid(_store3){
var dGrid = Ext.extend(Ext.grid.GridPanel,{
id :'buildGrid',
store : _store3,
border : false,
align : 'center',
height:267,
width:510,
columns : [
new Ext.grid.RowNumberer(),

{header: "Branch Code", width: 100, dataIndex: 'BRANCHCODE', sortable: true,id:'BRANCHCODE'},
{header: "Account No.", width: 140, dataIndex: 'ACCTNO', sortable: true,id:'ACCTNO'},
{header: "Account Name", width: 200, dataIndex: 'ACCTNAME', sortable: true},
],
initComponent : function(){
Ext.apply(this,{
});dGrid.superclass.initComponent.apply(this,arguments);
},
selModel : new Ext.grid.RowSelectionModel({singleSelect : true}),
listeners : {
'viewready' : function(g){
g.getSelectionModel().selectRow(0);
}
},
bbar : new Ext.PagingToolbar({
pageSize : 10,
displayInfo : true,
store : _store3,
plugins : new Ext.ux.ProgressBarPager()
})
});

var p = Ext.getCmp('employee_panel');
var n = new dGrid();
p.items = null;
p.add(n);
p.doLayout();
}

Condor
26 Nov 2010, 2:37 AM
There is only ONE Ext.MessageBox instance, so when a message is showing and you show another message the first message is replaced.

mond
26 Nov 2010, 2:45 AM
my code is working right when you manually input the text. but when i trigger the search button that sending ajax request.
the submittion is not working right. automatically closes the message box.

hope to your reply.

Condor
26 Nov 2010, 4:24 AM
Again, the messagebox you use for the error message and the messagebox you use for the request progress are the SAME messagebox!

If you show the error message first and then the progress, the progress will replace the error message and hiding the progress will hide the messagebox.