var iWidth = parseInt(this.getAttribute('width'));
var iHeight = parseInt(this.getAttribute('height'));
var aColumns = [];
var aChildren = bb.xml.getChildNodesByTagNameNS(this.modelNode, 'http://www.extjs.com/ext20', 'gridColumn'), i = 0, oChild;
while(oChild = aChildren[i++]){
aColumns.push( {
header: oChild.getAttribute('header'),
width: parseInt(oChild.getAttribute('width'), 10),
dataIndex: oChild.getAttribute('dataIndex'),
sortable: oChild.getAttribute('sortable') != 'false'
} );
}
if(!this._.store){
bb.command.trace('Ext.data.Store is not defined, please define Ext.data.Store before defining your Ext.grid.GridPanel',this,3);
return;
}
// create the grid
this._.grid = new Ext.grid.GridPanel({
store: this._.store,
columns: aColumns,
width: iWidth,
height: iHeight
});
this._.grid.render(this.viewNode);
this._.store.load();
var oTarget = this.selectSingleNode( this.getAttribute('for') );
var aFields = [];
var aChildren = bb.xml.getChildNodesByTagNameNS(this.modelNode, 'http://www.extjs.com/ext20', 'xmlDataField'), i = 0, oChild;
while(oChild = aChildren[i++])
aFields.push( oChild.getAttribute('name') );
// create the Data Store
oTarget._.store = new Ext.data.Store({
// load using HTTP
url: this.getAttribute('url'),
// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
// records will have an "Item" tag
record: this.getAttribute('record')
}, aFields)
});
Integrating ExtJS JavaScript Library with Backbase
Description
Description
One of the great advantages of Backbase is that it easily integrates with
third-party widgets. In this example we will demonstrate how you can combine Backbase
widgets with the Ext JS Javascript Library.
In this example we will implement the Ext JS XML Grid to enable user interaction (e.g. sort-columns, column drag and drop, etc.).
Live Example
Integrating with Backbase
The first requirement for Ext JS to work inside any web application
is to include the <script> to load the Ext JS JavaScript library:
In TDL (Tag Definition Language) we create a Ext JS namespace and two different tags:
ext:xmlGrid which wraps the Ext.grid.GridPanel
ext:xmlDataStore which wraps the Ext.data.Store combined with Ext.data.XmlReader
Because we declare the tags inside TDL, we can now use them and declare a Ext JS widget, just as any other widget would be declared, using XML.
The code from the live example is shown in the following listing:
The code for defining those tags is shown in the following listing (note the instantiation of the Ext code in the
DOMNodeInsertedIntoDocument handlers):
var iWidth = parseInt(this.getAttribute('width'));
var iHeight = parseInt(this.getAttribute('height'));
var aColumns = [];
var aChildren = bb.xml.getChildNodesByTagNameNS(this.modelNode, 'http://www.extjs.com/ext20', 'gridColumn'), i = 0, oChild;
while(oChild = aChildren[i++]){
aColumns.push( {
header: oChild.getAttribute('header'),
width: parseInt(oChild.getAttribute('width'), 10),
dataIndex: oChild.getAttribute('dataIndex'),
sortable: oChild.getAttribute('sortable') != 'false'
} );
}
if(!this._.store){
bb.command.trace('Ext.data.Store is not defined, please define Ext.data.Store before defining your Ext.grid.GridPanel',this,3);
return;
}
// create the grid
this._.grid = new Ext.grid.GridPanel({
store: this._.store,
columns: aColumns,
width: iWidth,
height: iHeight
});
this._.grid.render(this.viewNode);
this._.store.load();
var oTarget = this.selectSingleNode( this.getAttribute('for') );
var aFields = [];
var aChildren = bb.xml.getChildNodesByTagNameNS(this.modelNode, 'http://www.extjs.com/ext20', 'xmlDataField'), i = 0, oChild;
while(oChild = aChildren[i++])
aFields.push( oChild.getAttribute('name') );
// create the Data Store
oTarget._.store = new Ext.data.Store({
// load using HTTP
url: this.getAttribute('url'),
// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
// records will have an "Item" tag
record: this.getAttribute('record')
}, aFields)
});