Tree: Retriving the data from database and showind as a node of tree.
//creating a treePanel.
var tree = Ext.create('Ext.tree.Panel',{
width:400,
id:'Tree_id',
height:700,
id:'Tree_id',
renderTo: Ext.getBody()
//listeners:{'click':function(node,event){alert('hi');}}
});
//root node config..
tree.setRootNode({
text:'Poll',
visible: false
});
//Return the object of root node of tree.
var root = tree.getRootNode();
//Append the child on root node.
var OpenPoll = root.appendChild({
text:'OpenPoll',
id: 'OpenPoll_id'
});
var ClosedPoll = root.appendChild({
text:'ClosedPoll',
id:'OpenPoll_id'
});
//on each call this function appaend child on root node
function insertNode(rec,root,parent){
var tmpCls = 'treeLock';
//node text will be shown as FullQuestion on each call this will append as a child of root.
parent.appendChild({
text:rec.FullQuestion,
id:rec.QuestionID,
leaf:true
});
}
//this ajax call will request the cfm page and cfm pge respond with data that will append as a child of root.
Ext.Ajax.request({
url: '../db_query/TreeQuery.cfm',
disableCaching: true,
//if cfm page respond successfully then the respond data will be read by Ext.decode function.
success: function(response){
obj = Ext.decode(response.responseText);
if(obj.success){
//here rec will contain one row for geting all row Ext.each will fetch all the row sequentially.
Ext.each(obj.QuestionInfos,function(rec){
var dt = new Date();
if(rec.StartDateOfVote != '') {
//alert(rec.EndDateOfVote);
var TodayDate = Ext.Date.format(dt,'Y-m-d H:i:s');
if(TodayDate
tree.expandAll();
});
}
else {
Ext.Msg.alert(response);
}
},
failure: function(response){
Ext.Msg.alert(response);
}
});
coldfusion page for query will be ....