PDA

View Full Version : Problem with Ext.selection.CheckboxModel



hellocdef
20 Nov 2013, 1:40 AM
i have a problem, a gird add into tabpannel. first, it is work. i close the tab, add a new grid tab, checkbox not work.
version: extjs4.2


Ext.require('Ext.container.Viewport');
Ext.application({
name: 'App',
appFolder: 'app',
controllers: ['Books'],
launch: function() {
Ext.create('Ext.container.Viewport', {
layout: {
type: 'vbox',
align: 'stretch'
},
items: [
{
xtype: 'tabpanel',
flex: 1,
items: [
{xtype: 'bookList', flex: 1, closable : true}
]
},
{xtype: 'actionPanel', flex: 1}
]
})
}

});



Ext.define('App.model.Book', {
extend: 'Ext.data.Model',
fields: ['id', 'title', 'pages', 'numChapters', 'topic', 'publisher', 'isbn', 'isbn13']

})



Ext.define('App.store.Book', {
extend: 'Ext.data.Store',
model: 'App.model.Book',
proxy: {
type: 'ajax',
url: 'data/books.json',
reader: {
type: 'json',
root: 'books'
}
}
})



Ext.define('App.view.book.Grid', {
extend: 'Ext.grid.Panel',
alias: 'widget.bookList',
title: 'Books',
selModel: Ext.create('Ext.selection.CheckboxModel'),
initComponent: function() {
this.store = 'Book';
this.columns = [
Ext.create('Ext.grid.RowNumberer'),
{text: "Title", width: 120, dataIndex: 'title', sortable:true},
{text: "Pages", width: 120, dataIndex: 'pages', sortable:true},
{text: "Topic", width: 115, dataIndex: 'topic', sortable:true},
{text: "Publisher", width: 100, dataIndex: 'publisher', sortable: true}
];
this.viewConfig = {
forceFit: true
};
this.callParent(arguments);
}
})



Ext.define('App.view.book.ActionPanel', {
extend: 'Ext.panel.Panel',
alias: 'widget.actionPanel',
title: "Action",
bodyPadding: 7,
initComponent: function() {
this.dockedItems = [
{
xtype: 'toolbar',
dock: 'top',
items: [
{
action: 'add',
xtype: 'button',
text: 'Add'
}
]
}
];

this.callParent(arguments);
}
})



Ext.define('App.controller.Books', {
extend: 'Ext.app.Controller',
stores: ['Book'],
models: ['Book'],
views: ['book.Grid','book.ActionPanel'],
refs: [
{ref: 'main', selector: 'tabpanel'}
],
init: function() {
this.getBookStore().load({
});

this.control({
'button[action=add]': {
click: this.addGrid
}
});
},
addGrid: function() {
this.getMain().add({
xtype: 'bookList', closable : true
})
}
})

Gary Schlosberg
20 Nov 2013, 12:46 PM
In which specific version of ExtJS are you seeing this issue? Ext 4.2.1?

hellocdef
20 Nov 2013, 4:31 PM
Version Number: 4.2.1.883
Release Date: May 16, 2013

penot
20 Nov 2013, 8:22 PM
Tab closeAction default hide

Then close after added duplicated bookLabel

add code



this.getMain().add({
xtype: 'bookList', closable : true, closeAction : "destroy"
})

hellocdef
20 Nov 2013, 9:00 PM
I try closeAction : "destroy", but not work? The closeAction property 's default value is 'destroy'

penot
20 Nov 2013, 9:56 PM
try init selModel



Ext.define('App.view.book.Grid', {
extend: 'Ext.grid.Panel',
alias: 'widget.bookList',
title: 'Books',
initComponent: function() {
this.store = 'Book';
this.selModel = Ext.create('Ext.selection.CheckboxModel');
this.columns = [
Ext.create('Ext.grid.RowNumberer'),
{text: "Title", width: 120, dataIndex: 'title', sortable:true},
{text: "Pages", width: 120, dataIndex: 'pages', sortable:true},
{text: "Topic", width: 115, dataIndex: 'topic', sortable:true},
{text: "Publisher", width: 100, dataIndex: 'publisher', sortable: true}
];
this.viewConfig = {
forceFit: true
};
this.callParent(arguments);
}
});

hellocdef
20 Nov 2013, 10:40 PM
Ext.define('App.view.book.Grid', {
extend: 'Ext.grid.Panel',
alias: 'widget.bookList',
title: 'Books',
initComponent: function() {
this.store = 'Book';
this.selModel = Ext.create('Ext.selection.CheckboxModel');
this.columns = [
Ext.create('Ext.grid.RowNumberer'),
{text: "Title", width: 120, dataIndex: 'title', sortable:true},
{text: "Pages", width: 120, dataIndex: 'pages', sortable:true},
{text: "Topic", width: 115, dataIndex: 'topic', sortable:true},
{text: "Publisher", width: 100, dataIndex: 'publisher', sortable: true}
];
this.viewConfig = {
forceFit: true
};
this.callParent(arguments);
}
});



It is work, thanks everyone!
but why?
I think it is a bug.