PDA

View Full Version : XmlStore question



StyleWarz
13 Jul 2009, 8:43 AM
Hey there,

i'm trying this:


Admin.Layouts.Model = Ext.data.Record.create([
{
name: 'Id',
mapping: '@id',
type: 'int'
},{
name: 'Name',
mapping: '@name',
type: 'string'
},{
name: 'Language',
mapping: '@language',
type: 'string'
},{
name: 'Content',
mapping: '@content',
type: 'string'
}
]);

Admin.Layouts.Store = new Ext.data.XmlStore({
storeId: 'layoutsStore',
url: '/api/content',
autoLoad: true,

record: 'Content',
idPath: 'id',
totalRecords: '@TotalResults',
fields: Admin.Layouts.Model
});

Admin.RowEditor = new Ext.ux.grid.RowEditor({
saveText: 'Update'
});

Admin.Layouts.Grid = new Ext.grid.GridPanel({
store: Admin.Layouts.Store,
region: 'center',
margins: '0 5 5 5',
autoExpandColumn: 'name',
plugins: [ Admin.RowEditor ],
tbar: [{
iconCls: 'icon-user-add',
text: 'Add Content',
handler: function() {
var e = new Admin.Layouts.Model({
name: 'New Content',
language: 'en',
content: ''
});
Admin.RowEditor.stopEditing();
Admin.Layouts.Store.insert(0, e);
Admin.Layouts.Grid.getView().refresh();
Admin.Layouts.Grid.getSelectionModel().selectRow(0);
Admin.RowEditor.startEditing(0);
}
},{
ref: '../removeBtn',
iconCls: 'icon-user-delete',
text: 'Remove Content',
disabled: true,
handler: function() {
Admin.RowEditor.stopEditing();
var s = Admin.Layouts.Grid.getSelectionModel().getSelections();
for(var i = 0, r; r = s[i]; i++){
Admin.Layouts.Store.remove(r);
}
}
}],

columns: [{
id: 'id',
header: 'ID',
dataIndex: 'id',
width: 20,
readOnly: true
},{
id: 'name',
header: 'Name',
dataIndex: 'name',
width: 220,
sortable: true,
editor: {
xtype: 'textfield',
allowBlank: false
}
},{
id: 'language',
header: 'Language',
dataIndex: 'language',
width: 60,
sortable: true,
editor: {
xtype: 'textfield',
allowBlank: false
}
}]
});
Most of the stuff is copied from 3.0 samples. http://extjs.com/deploy/dev/examples/grid/row-editor.html and the API for XmlStore.

Any ideas why my Grid won't show any records? It gets this as result:


<?xml version="1.0" encoding="UTF-8"?>
<Contents>
<Content language="en_US" name="asdf" content="sdfsdf" id="1"></Content>
<Content language="en_US" name="shizbiz" content="oinkafoo" id="2"></Content>
</Contents>


Any idea what i am doing wrong?

best regards