Created
September 9, 2013 10:43
-
-
Save sunvisor/6494017 to your computer and use it in GitHub Desktop.
Grid with grouping feature issue.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>ggrid</title> | |
<script src="http://cdn.sencha.com/ext/gpl/4.2.1/ext-all.js"></script> | |
<link rel="stylesheet" href="http://cdn.sencha.com/ext/gpl/4.2.1/resources/ext-theme-classic/ext-theme-classic-all.css"> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
Ext.define('MyStore1', { | |
extend: 'Ext.data.Store', | |
constructor: function(cfg) { | |
var me = this; | |
cfg = cfg || {}; | |
me.callParent([Ext.apply({ | |
storeId: 'MyStore1', | |
data: [ | |
{ | |
gid: 1, | |
lid: 1, | |
title: 'Group1: Line: 1' | |
}, | |
{ | |
gid: 2, | |
lid: 2, | |
title: 'Group2: Line: 2' | |
}, | |
{ | |
gid: 2, | |
lid: 3, | |
title: 'Group2: Line: 2' | |
}, | |
{ | |
gid: 2, | |
lid: 4, | |
title: 'Group2: Line: 2' | |
}, | |
{ | |
gid: 3, | |
lid: 5, | |
title: 'Group3: Line: 3' | |
}, | |
{ | |
gid: 3, | |
lid: 6, | |
title: 'Group3: Line: 3' | |
}, | |
{ | |
gid: 3, | |
lid: 7, | |
title: 'Group3: Line: 3' | |
}, | |
{ | |
gid: 3, | |
lid: 8, | |
title: 'Group3: Line: 3' | |
}, | |
{ | |
gid: 3, | |
lid: 9, | |
title: 'Group3: Line: 3' | |
}, | |
{ | |
gid: 4, | |
lid: 10, | |
title: 'Group4: Line: 4' | |
}, | |
{ | |
gid: 4, | |
lid: 11, | |
title: 'Group4: Line: 4' | |
}, | |
{ | |
gid: 4, | |
lid: 12, | |
title: 'Group4: Line: 4' | |
}, | |
{ | |
gid: 5, | |
lid: 13, | |
title: 'Group5: Line: 5' | |
}, | |
{ | |
gid: 5, | |
lid: 14, | |
title: 'Group5: Line: 5' | |
} | |
], | |
groupField: 'gid', | |
fields: [ | |
{ | |
name: 'gid' | |
}, | |
{ | |
name: 'lid' | |
}, | |
{ | |
name: 'title' | |
} | |
] | |
}, cfg)]); | |
} | |
}); | |
Ext.create('MyStore1'); | |
Ext.define('MyViewport', { | |
extend: 'Ext.container.Viewport', | |
layout: { | |
type: 'fit' | |
}, | |
initComponent: function() { | |
var me = this; | |
Ext.applyIf(me, { | |
items: [ | |
{ | |
xtype: 'gridpanel', | |
title: 'My Grid Panel', | |
store: 'MyStore1', | |
features: [ | |
{ | |
ftype: 'grouping', | |
startCollapsed: true | |
} | |
], | |
listeners: { | |
itemdblclick: { | |
fn: me.onGridpanelItemDblClick, | |
scope: me | |
} | |
}, | |
columns: [ | |
{ | |
xtype: 'gridcolumn', | |
dataIndex: 'gid', | |
text: 'Gid' | |
}, | |
{ | |
xtype: 'gridcolumn', | |
dataIndex: 'lid', | |
text: 'Lid' | |
}, | |
{ | |
xtype: 'gridcolumn', | |
dataIndex: 'title', | |
text: 'Title' | |
} | |
] | |
} | |
] | |
}); | |
me.callParent(arguments); | |
}, | |
onGridpanelItemDblClick: function(dataview, record, item, index, e, eOpts) { | |
console.log(record.data, item, index); | |
} | |
}); | |
Ext.create('MyViewport', { | |
renderTo: document.body | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment