mohaskuar
16 Jul 2012, 3:40 AM
//this is gird.js
Ext.ns('moha');
Ext.define('moha.cla', {
loadGrid:function(){
Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'int'},
'text', 'parent_id'
]
});
var store=Ext.create('Ext.data.Store', {
model: 'User',
loadMask: true,
//method: 'GET',
pageSize: 10,
proxy: { type: 'ajax',
url : 'grid.php',
reader: {
type: 'json',
root: 'results',
totalProperty: 'total'
},
actionMethods:'POST'
}
});
var par = new Object();
par['start'] = 0;
par['limit']=5;
store.load({params: par});
var ngrid=Ext.create('Ext.grid.Panel', {
renderTo:'content-panel' ,
store: store,
width: 400,
height: 200,
stripeRows: true,
title: 'Application Users',
columns: [
{
text: 'id',
width: 100,
sortable: false,
hideable: false,
dataIndex: 'id'
},
{
text: 'text',
width: 150,
dataIndex: 'text',
hidden:false
},
{
text: 'parent_id',
flex: 1,
dataIndex: 'parent_id'
}
],
bbar: new Ext.PagingToolbar({
pageSize: 5,
store: store,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
})
});
}
});
**//and when i call that function on grid2.js it works fine.. using this code**
Ext.onReady(function () {
var f = Ext.create('moha.cla', 'f');
f.loadGrid();
});
**but my problem occurs when i want to use the above way inside a content panel's item like this...in grid3.js**
var f = Ext.create('moha.cla', 'f');
//var g= f.loadGrid();
var contentPanel = {
id: 'content-panel',
region: 'center',
layout: 'card',
margins: '2 5 5 0',
activeItem: 0,
items:[
{
title:'load griiid here',
itemId:1
},
f.loadGrid(),//everything works fine if i comment out this line
{
xtype:'tabpanel',
title:'tab panel three',
html:'this is tab panel three',
itemId:3
}
],
border: true,
}
Ext.ns('moha');
Ext.define('moha.cla', {
loadGrid:function(){
Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'int'},
'text', 'parent_id'
]
});
var store=Ext.create('Ext.data.Store', {
model: 'User',
loadMask: true,
//method: 'GET',
pageSize: 10,
proxy: { type: 'ajax',
url : 'grid.php',
reader: {
type: 'json',
root: 'results',
totalProperty: 'total'
},
actionMethods:'POST'
}
});
var par = new Object();
par['start'] = 0;
par['limit']=5;
store.load({params: par});
var ngrid=Ext.create('Ext.grid.Panel', {
renderTo:'content-panel' ,
store: store,
width: 400,
height: 200,
stripeRows: true,
title: 'Application Users',
columns: [
{
text: 'id',
width: 100,
sortable: false,
hideable: false,
dataIndex: 'id'
},
{
text: 'text',
width: 150,
dataIndex: 'text',
hidden:false
},
{
text: 'parent_id',
flex: 1,
dataIndex: 'parent_id'
}
],
bbar: new Ext.PagingToolbar({
pageSize: 5,
store: store,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
})
});
}
});
**//and when i call that function on grid2.js it works fine.. using this code**
Ext.onReady(function () {
var f = Ext.create('moha.cla', 'f');
f.loadGrid();
});
**but my problem occurs when i want to use the above way inside a content panel's item like this...in grid3.js**
var f = Ext.create('moha.cla', 'f');
//var g= f.loadGrid();
var contentPanel = {
id: 'content-panel',
region: 'center',
layout: 'card',
margins: '2 5 5 0',
activeItem: 0,
items:[
{
title:'load griiid here',
itemId:1
},
f.loadGrid(),//everything works fine if i comment out this line
{
xtype:'tabpanel',
title:'tab panel three',
html:'this is tab panel three',
itemId:3
}
],
border: true,
}