BENN987 EXTCODE 2 - actionscript
Embed
You can embed this paste into a blog or website with this code:
<iframe class="codetidy" type="text/html" width="100%" src="http://codetidy.com/paste/embed/183" frameborder="0"></iframe>
/* GREG'S CODE TO RENDER GRAPHS & SEARCH - TEMPORARY */
function drawChartView
()
{
//Loop through each chart view
for(var i =
0; i
< chartViews.
length; i++
)
{
(function(){
var chartView = chartViews
[i
];

//Create a container DIV element for the chart
Ext.
getCmp("personsChart").
update("<div id=\""+chartView.
name+
"\"></div>");

//$("plotcanvas").append("<div id=\""+chartView.name+"\"></div>"); // OLD CODE
//Fetch the chart's data
chartView.
update(function(){
//After the update is complete, execute this code
//Define a chart click handler to set the filters of the grid view
function onBarClick
()
{
var filterVals = chartView.
getChartDataFilterValues(this.
index)[0];

var filters = chartView.
getFieldFilters();

for(var j =
0; j
< filters.
length; j++
)
{
setFilter
(filters
[j
].
filter.
field,filterVals
[j+
1],chartView
);

}
applyFilters
();

}
//Draw the chart, passing the ID of the DIV created above as the "canvas" property, and the click handler
chartView.
drawChart({canvas: chartView.
name, onBarClick: onBarClick
});

});

})();

}
}
/************************************/
/*** OTHER CODE IN BETWEEN HERE *****/
/************************************/
/* VARS FOR PERSONS MODULE */
var store =
"";

var colModel =
"";

var chartViews =
"";

/* END VARS FOR PERSONS MODULE */
MyDesktop.
GridWindow = Ext.
extend(Ext.
app.
Module,
{
id:
'grid-win',

init :
function(){
this.
launcher =
{
text:
'Persons Module',

iconCls:
'icon-grid',

handler :
this.
createWindow,

scope:
this
}
/* XML PERSONS OBJECT */
//Load the Module by requesting its definition XML from the server
var app = PTS.
ApplicationManager.
loadApplication("PersonDetails_File");

//Get the Person Details View object
view = app.
getView("PersonDetailsGridView");

//Create the Ext Js Store and ColumnModel objects from the PTS View object
store = view.
getDataModel(new PTS.
DataView.
Ext.
ExtDataStoreAdapter());

colModel = view.
getFieldModel(new PTS.
DataView.
Ext.
ExtColumnModelAdapter());

var viewFilters = view.
getFieldFilters(true);

var filtersForm = $
("<div id=\"filtersdiv\"><form id=\"filtersform\" method=\"post\" action=\"\"><div id=\"autofilters\"></div><button onclick=\"applyFilters(); return false;\">Apply Filters</button><button onclick=\"clearFilters(); return false;\">Clear Filters</button></form></div>");

var filtersFormFilterContainer = filtersForm.
find("#autofilters");

//Get chart views for this module
chartViews = app.
getViewsByType("ChartView");

//function to recursively draw the filters for each view/sub-view
var drawFilters =
function(filters,drawElem
)
{
for(var i =
0; i
< filters.
length; i++
)
{
var filter = filters
[i
];

if(filter.
filter.
length)
{
//Filter is a subview and has an array of filters as its value
//Draw a fieldset
var fieldSet = $
("<fieldset style=\"width:25%\"></fieldset>");

fieldSet.
append("<legend>"+filter.
fieldLabel+
"</legend>");

//Recursively draw all child filters
drawFilters
(filter.
filter,fieldSet
);

drawElem.
append(fieldSet
);

drawElem.
append("<br/>");

}
else
{
drawFilter
(filter.
filter,drawElem
);

}
}
};

//Draws an individual filter
function drawFilter
(filter,drawElem
)
{
//Get the label to use for the filter edit
var filterLabel = filter.
label;

//Draw a different edit control depending on the filter type
if(filter.
type ==
"text")
{
drawElem.
append("<label>"+filterLabel+
": </label><input class=\"extfilter\" id=\""+filter.
field.
replace(/\.
/g,
"-")+
"\" type=\"text\"/><br/>");

}
else if(filter.
type ==
"select")
{
var selHTML =
"<label>"+filterLabel+
": </label><select class=\"extfilter\" id=\""+filter.
field.
replace(/\.
/g,
"-")+
"\"><option value=\"\"></option>";

for(var j =
0; j
< filter.
filterOptions.
length; j++
)
selHTML +=
"<option value=\""+filter.
filterOptions[j
].
value+
"\">"+filter.
filterOptions[j
].
text+
"</option>";

selHTML +=
"</select><br/>";

drawElem.
append(selHTML
);

}
}
drawFilters
(viewFilters,filtersFormFilterContainer
);

personModuleFilterHTML = $
("<div></div>").
append(filtersForm
);

personModuleFilterHTML = personModuleFilterHTML.
html();

function clearFilters
()
{
$
(".extfilter").
val('');

view.
clearFieldFilters(true);

}
},

createWindow:
function() {
var desktop =
this.
app.
getDesktop();

var win = desktop.
getWindow('grid-win');

if(!win
) {
win = desktop.
createWindow ({
id:
'grid-win',

title:
'Person Module',

width:
824,

height:
630,

iconCls:
'icon-grid',

shim:
false,

animCollapse:
false,

border:
false,

constraintHeader:
true,

layout:
'border',

defaults:
{
collapsible:
false,

split:
true,

border:
false,

frame:
false
},

items:
[
{
title:
false,

region:
'north',

height:
25,

items: myTopToolbar

},
{
title:
'Search Pane',

region:
'west',

collapsible:
true,

width:
150,

layout:
'accordion',

items:
[{
title:
'Search',

html: personModuleFilterHTML

},
{
title:
'Saved Searches',

html:
'Saved Search Results'
}]
},
{
title:
'Data',

region:
'center',

items:

new Ext.
TabPanel({
activeTab:
0,

items:
[
{
title:
'Persons',

xtype:
'grid',

loadMask:
true,

height:
500,

store: store,

cm: colModel,

stripeRows:
true,

bbar:
new Ext.
PagingToolbar({pageSize:
10, store: store, displayInfo:
true})
},
{
title:
'Charts & Graphs',

afterRender: drawChartView
(),

id:
'personsChart'
}
]
})
}
]
})
}
win.
show();

}
});
