PDA

View Full Version : Dynamic Grid Construct Issue.



swiji2000
7 Nov 2012, 10:38 PM
Hi,

I am trying to create dynamic grid panel using response xml .

The grid is displayed but data not populated.
Please help me to solve this issue.

Here is my code:

loadData : function() {

var sessionId=Ext.getCmp('sessionStore').value;
var buId=Ext.getCmp('buidStore').value;
var xmlFileName="D:\\Workspace4.1\\xgenerationV4.3.EXTJS\\resources\\xml\\viewsBuilder.xml";

Ext.Ajax.request({
type: 'ajax',
url: '/dailypriorityactions/ViewsBuilderCommonServlet',
disableCaching: false,
params: {
asession: sessionId,
buid: buId,
fileName: xmlFileName
},
reader: {
type: 'xml'
},
scope: this,
success: this.onViewLoadSuccess
});

},

onViewLoadSuccess : function(response, opts){

var gridColumns = [];
var storeFields = [];
var storeData = [];

var str = response.responseText;

alert(str);
var dq = Ext.DomQuery;
//var responseXML = response.xml;
var columnArr=new Array();
var itemNodes = Ext.DomQuery.select('nodes', response.responseXML);

debugger;


Ext.each(itemNodes, function(item){


for(var i=0;i<item.childNodes.length;i++){

storeData[i]={};
// storeData[i]=item.childNodes[i].nodeName+":"+item.childNodes[i].textContent;
// storeData[i]=":";
storeData[i]=item.childNodes[i].textContent;

// model.set(item.childNodes[i].nodeName,item.childNodes[i].textContent);

storeFields[i] = {};
storeFields[i].name = item.childNodes[i].nodeName;
storeFields[i].type = 'String';

gridColumns[i]={};
gridColumns[i].text=item.childNodes[i].nodeName;
gridColumns[i].flex=1
gridColumns[i].dataIndex=item.childNodes[i].nodeName;
}
}, this);

Ext.getCmp('dynamicAlertView').headerCt.add(gridColumns);

// var jsonData = Ext.util.JSON.decode(response.responseText);

// var jsonData= Ext.decode(response.responseText);

Ext.define('model', {
extend: 'Ext.data.Model',
fields: storeFields
});


var store = new Ext.data.Store({
// fields: storeFields,
data:storeData,
model:model,
autoLoad: true
});

Ext.getCmp('dynamicAlertView').bindStore(store);
}


Please help me to solve this issue.. its highly priority task.

Thanks in advance.

mitchellsimoens
9 Nov 2012, 10:53 AM
Why not use the metachange event on the store and have the store load the xml?

Jangla
26 Mar 2013, 3:20 PM
Why not use the metachange event on the store and have the store load the xml?

From the docs:



Fires when this proxy's reader provides new metadata. Metadata usually consists of new field definitions, but can include any configuration data required by an application, and can be processed as needed in the event handler. This event is currently only fired for JsonReaders. Note that this event is also propagated by Ext.data.Store (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store), which is typically where it would be handled.