PDA

View Full Version : Extjs4.2.1- after loading data manually, store.group() function of store not working.



Vrushali.Suryawanshi
21 Jan 2014, 3:05 AM
After loading Jsondata in grid manually using loadData() or loadRawData(), group() function for store not working, giving me Unable to get property 'indexOf' of undefined or null reference js error. I want to group the records dynamically.


can any one help?

mdnaveed42
21 Jan 2014, 4:19 AM
Hi,

I didn't find any issue, added sample code for your reference.


Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone'],
groupField: 'name',
data:{'items':[
{ 'name': 'Lisa', "email":"[email protected]", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"[email protected]", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"[email protected]", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"[email protected]", "phone":"555-222-1254" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});


var grouping = Ext.create('Ext.grid.feature.Grouping',{
startCollapsed: true,
});




Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
features: [grouping],
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});


var store = Ext.data.StoreManager.lookup('simpsonsStore');
var rawData = [
{ 'name': 'Johnm', "email":"[email protected]", "phone":"555-111-1224" },
{ 'name': 'Alex', "email":"[email protected]", "phone":"555-222-1234" }]
store.loadRawData(rawData, true);
store.group('email');


Hope this helps you :)

Thanks,
MD Naveed

Vrushali.Suryawanshi
23 Jan 2014, 12:47 AM
Thank you.

Vrushali.Suryawanshi
23 Jan 2014, 1:45 AM
Thank you.

mdnaveed42
23 Jan 2014, 2:54 AM
Hi,

Please mark it as Answered.


Thanks,
Md Naveed