Render object in form html tag in extjs

516 views Asked by At

I'm using extjs 3.4. I have a form. Inside I want to display some ajax content. But i'm getting [object object] whenever alert that variable. I tried stringify Json.decode But no luck. Here is my code,

var sourcePath = new Ext.data.Store({
                reader: new Ext.data.JsonReader({
                    fields: ['path'],
                    root: 'rows'
                }),
                proxy: new Ext.data.HttpProxy({
                    url: '/plugin/BODImageImport/admin/getsourcepath'
                }),
                autoLoad: true
            });

And my form,

var bodimportForm = new Ext.form.FormPanel({
            html: "<p>Imgae source: <b>"+ sourcePath +"</b> folder in root directory</p>",
            url: '/plugin/BODImageImport/admin/import',

any help or hint would be very helpful for me.

Update:

My Json is looks like this,

{"rows":[{"path":"bodyshop\/tr\/media\/inbox"}]}

I just trying to get that path in html tag.

Update: When i'm printing objects using console.log() I'm getting below things. But I don't know how to get my value, Console

1

There are 1 answers

4
Cyril Cherian On

Here sourcePath is a store instance.

So you cannot do html:

Imgae source: "+ sourcePath +"

In order to get the value inside the store you must do

//index you are interested
m = sourcePath.getAt( index ) //this will give the model m
//m.path to get the path

and inside your reader

reader: new Ext.data.JsonReader({
                    fields: ['path'],
                    root: 'rowsDir'
                }),

should have been

reader: new Ext.data.JsonReader({
                    fields: ['path'],
                    root: 'rows'
                }),

since your json root is rows and not rowsDir