Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Ext.namespace('App.view.helper');
- // source: the Ext.Container to be placed, or JSON hash to be placed
- // destination: the ID (string) of the target Ext.Container.
- // replace: true|false If true removes the Ext.Container referred to by
- // destination and adds source to the destinations parent.
- // append: true|false If replace is false, then append will determine whether
- // the destinations contents are appended to or replaced
- App.view.helper.renderLayout = function (source,destination,replace,append){
- if (typeof replace == 'undefined'){
- replace = false;
- }
- if (typeof append == 'undefined'){
- append = false;
- }
- if ((typeof destination == 'string') || (destination instanceof String)){
- // it's a string so treat it as an ID of a Ext.Container
- var targetParent = Ext.getCmp(destination);
- do_container_layout(source, targetParent,replace, append);
- }
- else {
- // No "ID" passed so lets just try and render it
- do_container_layout(source, destination,replace, append);
- }
- function do_container_layout(source_container,destination_container,replace_container, append_to_container){
- if (replace_container == true) {
- parent_container = destination_container.ownerCt;
- parent_container.remove(destination_container, true);
- parent_container.add(source_container);
- source_container.doLayout();
- parent_container.doLayout();
- } else {
- if (append_to_container == false){
- // get all existing items into an array
- var items = [];
- destination_container.items.each(function(item, index, len){
- items.push(item);
- });
- // now remove them from the container, you must use remove so that the correct
- // events are called and destory methos invoked
- while (items.length > 0){
- destination_container.remove(items.pop());
- }
- }
- destination_container.add(source_container);
- source_container.doLayout();
- destination_container.doLayout();
- }
- }
- }
Add Comment
Please, Sign In to add comment