View Full Version : Need your help in panels

5 Nov 2012, 11:35 PM
Ext.define('mailtrack.model.TemplateContent', {
extend: 'Ext.data.Model',
fields: [


Ext.define('mailtrack.store.TemplateContents', {
extend: 'Ext.data.Store',
model: 'mailtrack.model.TemplateContent',
autoLoad: true,
storeId: 'TemplateContentStoreId',
type: 'ajax',
reader: {
type: 'json',
root: 'Block'
afterRequest:function( request, success )
console.log( 'request here' + request );
console.log( 'success result here' + success );

MY JSON OBJECT data::{"Block":[{"blockcontentId":0,"content":"swapna11155555555555","createdOn":"2010-10-10T00:00:00+05:30","id":6,"updatedOn":"2010-10-10T00:00:00+05:30"},{"blockcontentId":0,"content":"padma22222","createdOn":"2010-10-10T00:00:00+05:30","id":4,"updatedOn":"2010-10-10T00:00:00+05:30"},{"blockcontentId":0,"content":"swapna111","createdOn":"2010-10-10T00:00:00+05:30","id":5,"updatedOn":"2010-10-10T00:00:00+05:30"},{"blockcontentId":0,"content":"Xpressdocs","createdBy":"maanasa","createdOn":"2010-10-10T00:00:00+05:30","id":1,"updatedBy":"malavika","updatedOn":"2010-10-10T00:00:00+05:30"}]}

i want to retrieve content of record in store.

Could u please help me in this.
findRecord on store is not working for me to select record in store.

Thanks in advance.

5 Nov 2012, 11:46 PM
i want to retrieve content of record in store.

Which record would you like to retrieve content?

findRecord on store is not working for me to select record in store.

What do you mean? store.findRecord() returns the first matching record in store that match the criteria.

5 Nov 2012, 11:48 PM
Show us your panel. And how do you want the data to be presented? You will need a tpl in your panel to apply the data or something like that, a Panel it is just a basic container so you have to provide it with the logic to display your json.

6 Nov 2012, 2:14 AM
In that store i want to retrieve first object so that i can get that field value which will display on panel.

var blockStore = new Ext.data.Store({
storeId : 'blockStore',
model : 'Block',
data : [{
id : 1,
content : '<div>Hi welcome to sencha</div>'
}, {
id : 2,
content : '<div>Thanks for visiting us.</div>'
autoLoad : true

Ext.require(['Ext.button.Button', 'Ext.data.proxy.Ajax',
'Ext.chooser.InfoPanel', 'Ext.chooser.IconBrowser',
'Ext.chooser.Window', 'Ext.ux.DataView.Animated',

xtype : 'panel',
id : 'third_block',
width : 700,
height : 123,
hideBorders : false,
bodyBorder : false,
border : true,
styleHtmlContent : true,
html : Ext.data.StoreMgr.lookup('blockStore').findRecord('id',1).get('content')

Its working statically..but when i am trying to get this data dynamically , am not able to retrieve object for store to get content field value.

My requirement is to display content (html/text) on panel by getting that content from database.
Please have a look at json data which i am getting from database.

6 Nov 2012, 2:27 AM
You can add a listener to the store:

listeners :
load : function(/*arguments, check docs but there is a records one*/)
//get the value from records.
//update the body with the value you want

6 Nov 2012, 2:35 AM
My problem is to get record and values in that only.
Not able get records from store.

6 Nov 2012, 2:39 AM
Your problem, as far as I can see, is that you are trying to get the value of the record from an static place (html config option), and the value is not there. If you want to get the value when it is loaded you have to retrieve it in the listener.

If you add the listener I told you and you console.log(arguments); you will see the array of records with their values, there you can update the body with the value you want.