PDA

View Full Version : Grid start with grouping feature disabled by default



andromeda1966
26 Mar 2014, 6:26 AM
Hi,
I have added grouping feature to a grid without problem, it work perfectly.
I know that there are enable() and disable() functions to enable and disable this feature on the grid, but what I need is to start the grid with grouping feature disabled.
So how can I start grid with grouping feature disabled by default ?

Thanx in advance
Mauro

gmcgrath
26 Mar 2014, 3:42 PM
I'm not sure I understand exactly, but is this what you are looking for?

(https://fiddle.sencha.com/#fiddle/4ic)Ext.define('App.MyStore', {
(https://fiddle.sencha.com/#fiddle/4ic) extend: 'Ext.data.Store',
fields: ['name', 'email', 'phone'],
data: [
{ 'name': 'Lisa', "email": "lisa@simpsons.com", "phone": "555-111-1224" },
{ 'name': 'Bart', "email": "bart@simpsons.com", "phone": "555-222-1234" },
{ 'name': 'Homer', "email": "home@simpsons.com", "phone": "555-222-1244"},
{ 'name': 'Lisa', "email": "lisa@simpsons.com", "phone": "555-111-1224" },
{ 'name': 'Bart', "email": "bart@simpsons.com", "phone": "555-222-1234" },
{ 'name': 'Homer', "email": "home@simpsons.com", "phone": "555-222-1244"},
{ 'name': 'Lisa', "email": "lisa@simpsons.com", "phone": "555-111-1224" },
{ 'name': 'Bart', "email": "bart@simpsons.com", "phone": "555-222-1234" },
{ 'name': 'Homer', "email": "home@simpsons.com", "phone": "555-222-1244"},
{ 'name': 'Lisa', "email": "lisa@simpsons.com", "phone": "555-111-1224" },
{ 'name': 'Bart', "email": "bart@simpsons.com", "phone": "555-222-1234" },
{ 'name': 'Homer', "email": "home@simpsons.com", "phone": "555-222-1244"},
{ 'name': 'Lisa', "email": "lisa@simpsons.com", "phone": "555-111-1224" },
{ 'name': 'Bart', "email": "bart@simpsons.com", "phone": "555-222-1234" },
{ 'name': 'Homer', "email": "home@simpsons.com", "phone": "555-222-1244"},
{ 'name': 'Lisa', "email": "lisa@simpsons.com", "phone": "555-111-1224" },
{ 'name': 'Bart', "email": "bart@simpsons.com", "phone": "555-222-1234" },
{ 'name': 'Homer', "email": "home@simpsons.com", "phone": "555-222-1244"}
]
});
Ext.define('App.MyGrid', {
extend: 'Ext.grid.Panel',
alias: 'widget.mygrid',
title: 'Simpsons',
width: 500,
features: [{
ftype: 'grouping'
}],
store: Ext.create('App.MyStore'),
columns: [
{ header: 'Name', dataIndex: 'name' },
{ header: 'Email', dataIndex: 'email', flex: 1 },
{ header: 'Phone', dataIndex: 'phone' }
]
});

Ext.onReady(function () {
Ext.widget('mygrid', {
title: 'First Panel',
renderTo: Ext.getBody(),
listeners: {
itemclick: function(){
console.log('itemclick');
}
}
});
});



https://fiddle.sencha.com/#fiddle/4ic

(https://fiddle.sencha.com/fiddle/4ic/preview)The user can still add a group at any point by using the column's menu, but the grid is not grouped on page load since the store's groupField is not set.

Gary Schlosberg
27 Mar 2014, 9:10 AM
Here's a thread with some additional information:
http://www.sencha.com/forum/showthread.php?250807

andromeda1966
1 Apr 2014, 1:36 AM
To start a grid without group you don't have to use group with store when the page is loaded, but you have to use it after maybe using a button and add 'group' to the store and enable grouping feature in the grid.

storeMain.group ('field5', 'ASC');
groupingFeature.enable();

Thanx
Mauro