View Full Version : Accessing parent element

25 Mar 2010, 5:29 AM
I want to show a confirm dialog when someone is trying to delete a record in a datagrid.

I do this by using:

}, onDelete : function(btn, ev) {
msg: 'Weet u zeker dat u dit bedrijf inclusief alle notities en contacten wilt verwijderen?',
buttons: Ext.Msg.YESNO,
fn: function() {
var index = this.getSelectionModel().getSelectedCell();
if (!index) {
return false;
var rec = this.store.getAt(index[0]);
The only problem is that "this" is not the EditorGridPanel inside the Ext.Msg.Show any more. So my question is how do I access the parent EditorGridPanel to call this.getSelectionModel().getSelectedCell(); inside the Ext.Msg.show for example?

25 Mar 2010, 5:31 AM
add a
scope: this
at the end of the listeners.

25 Mar 2010, 5:33 AM
Thanks so much. It's working. Where can I find this kind of information so I don't need to ask it here?

25 Mar 2010, 5:35 AM

25 Mar 2010, 7:07 AM
Removing records from a grid is working now. I have still one problem in the following situation:

total amount of records: 30
displayed per page in grid: 12

So the grid will have 3 pages of 12/12/6 records. When I'm at the first page and delete more than 6 records and then click on the last page button of the pager this will show an empty data grid.

A solution could be to update the pager on record creation/deletion. Any ideas?

25 Mar 2010, 7:29 AM

You may be interested in http://i131.photobucket.com/albums/p286/TimeTrialAnimal/hideinherited.jpg (http://s131.photobucket.com/albums/p286/TimeTrialAnimal/?action=view&current=hideinherited.jpg)

25 Mar 2010, 9:41 AM
Thanks again for answering. I'm getting better at reading the API.

myBorderPanel.get('companyGrid').addListener('celldblclick', function(grid, rowIndex, columnIndex, eventObject) {
if(columnIndex==0) {
var tabs = this.get('companyTabs');

for(i = 0; i < tabs.items.length; i++) {
var tab = tabs.items[i];

var modeltje = grid.getSelectionModel();
var clickedRow = grid.store.getAt(rowIndex);
var activeCompanyId = clickedRow.get('id');
}, myBorderPanel);

Currently the problem is that 'modeltje' is not a selectionModel and so selectRow is not working. I don't get why grid isn't returning a selectionmodel (it is returning an object but can't find out what kind of). The rest of the function is working fine. So the question is why is grid.getSelectionModel() not returning a SelectionModel?