PDA

View Full Version : Celledtiting 'edit' event and Button 'click' event



panbayi
26 Jan 2013, 9:42 PM
I have a grid of which plugin is cellediting,and I add a listener to detect the 'edit' event of it so when user input wrong value in it I can alert a MessageBox.At the same time,the grid has a toolbar which contains a button(let's call it 'cancel'),when user click 'cancel' button , the store will ignore the changes user made.
Here is the problem : when I click the 'cancel' button while I'm inputing in the cell,it's the cellediting's 'edit' event invoked not the 'click' event of 'cancel' button.

Any help will be appreciated.Thank you so much!

Farish
27 Jan 2013, 11:54 PM
without looking at some code, it would be difficult to say. Could you create a simple working case and put it on jsfiddle.net?

panbayi
28 Jan 2013, 2:57 AM
sorry,I can't get access to the url,SO I put the code here.

//I use MVC
//here is view
Ext.define('MyApp.view.MyPanel',{
//extend...
//alias...
//some other properties like 'titles','store'
initComponent : function(){
var me=this;
Ext.applyIf(me,{
columns : [
{
xtype : 'id',
dataIndex : 'uid',
editor : {
xtype : 'textfield'
}
}
{
xtype : 'name',
dataIndex : 'uname',
editor : {
xtype : 'textfield'
}
}
//...some other columns
],
dockedItems : [
{
xtype : 'toolbar',
dock : 'top',
items : [
{
xtype : 'button',//when I click this button,this button and the 'confirm' button will hide , the other buttons like 'edit','insert'will show.At the same time,the grid turns uneditable.
text : 'cancel',
id : 'cl'
},
{
xtype ; 'button',//when I click this button,the changes will be saved by store.sync()
text ; 'confirm',
id : 'ok'
},
//some buttons named 'edit','delete',insert'

]

}
],
plugins : [
Ext.create('Ext.grid.plugin.CellEditing',{
clickToEdit : 1,
listeners : {
'edit' : function(editor,ctx){
//I will send a request to check the value,if invalid, I alert a messagebox to remind the user
}
}
}
]
me.callParents(arguments);
})
}
});
//here is the controller
Ext.define('MyApp.controller.MyController',{
//extend ...
//requires
//views,I'm sure I add MyPanel here
//models ...
//stores ...
init : function(){
this.control({
'button[id=cl]' :{
click : me.cancel
},
'button[id=ok]' :{
click : me.confirm
}

})
},
cancel : function(){
alert('Changes will be ignored and button will hide');
},
confirm : function(){
alert('changes will be saved and grid turns uneditable');
}
});

//now is the problem ,when I click the 'cancel' button while I input wrong value in the cell(cursor in the cell),a messagebox is shown which means the 'click' event of the 'cancel' button is not fired but the 'edit' event is fired
//I wished the 'click' event will be fired not the 'edit' event of the cellediting

panbayi
28 Jan 2013, 10:19 PM
without looking at some code, it would be difficult to say. Could you create a simple working case and put it on jsfiddle.net?
Hi,I wondered whether you have checked this thread recently,so I reply again. Hope you can solve this or give me some advice!

Thank you!

Farish
28 Jan 2013, 11:50 PM
I am not much familiar with the MVC architecture but it could be that you have some syntax error in the ccontroller code which causes it not to work. Firstly, I dont know if you have copy/pasted your code or typed it in (or some parts). "define" is misspelled as "defien" in Ext.define in your controller. When you end this.controller(), you should put a semi-colon after it. Take a look at the MVC architecture example and compare your code:

http://docs.sencha.com/ext-js/4-0/#!/guide/application_architecture

panbayi
29 Jan 2013, 12:26 AM
I am not much familiar with the MVC architecture but it could be that you have some syntax error in the ccontroller code which causes it not to work. Firstly, I dont know if you have copy/pasted your code or typed it in (or some parts). "define" is misspelled as "defien" in Ext.define in your controller. When you end this.controller(), you should put a semi-colon after it. Take a look at the MVC architecture example and compare your code:

http://docs.sencha.com/ext-js/4-0/#!/guide/application_architecture

Thank you !

Hm?I typed it ,I'm sorry for the wrong word.My original code is somehow too long to put it here and there are a lot of Chinese words in it.

Thank you for you reply again!

Farish
29 Jan 2013, 12:32 AM
is it working now? please share the fix so that others having a similar problem may also benefit.

panbayi
29 Jan 2013, 5:50 PM
is it working now? please share the fix so that others having a similar problem may also benefit.
Not yet...,I hope someone can give me some advice