Guest User

Untitled

a guest
Jun 14th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. Ext.namespace('App.view.helper');
  2.  
  3. // source: the Ext.Container to be placed, or JSON hash to be placed
  4. // destination: the ID (string) of the target Ext.Container.
  5. // replace: true|false If true removes the Ext.Container referred to by
  6. // destination and adds source to the destinations parent.
  7. // append: true|false If replace is false, then append will determine whether
  8. // the destinations contents are appended to or replaced
  9. App.view.helper.renderLayout = function (source,destination,replace,append){
  10. if (typeof replace == 'undefined'){
  11. replace = false;
  12. }
  13. if (typeof append == 'undefined'){
  14. append = false;
  15. }
  16.  
  17. if ((typeof destination == 'string') || (destination instanceof String)){
  18. // it's a string so treat it as an ID of a Ext.Container
  19. var targetParent = Ext.getCmp(destination);
  20. do_container_layout(source, targetParent,replace, append);
  21. }
  22. else {
  23. // No "ID" passed so lets just try and render it
  24. do_container_layout(source, destination,replace, append);
  25. }
  26.  
  27. function do_container_layout(source_container,destination_container,replace_container, append_to_container){
  28.  
  29. if (replace_container == true) {
  30. parent_container = destination_container.ownerCt;
  31. parent_container.remove(destination_container, true);
  32. parent_container.add(source_container);
  33. source_container.doLayout();
  34. parent_container.doLayout();
  35. } else {
  36. if (append_to_container == false){
  37.  
  38. // get all existing items into an array
  39. var items = [];
  40. destination_container.items.each(function(item, index, len){
  41. items.push(item);
  42. });
  43.  
  44. // now remove them from the container, you must use remove so that the correct
  45. // events are called and destory methos invoked
  46. while (items.length > 0){
  47. destination_container.remove(items.pop());
  48. }
  49. }
  50. destination_container.add(source_container);
  51. source_container.doLayout();
  52. destination_container.doLayout();
  53. }
  54. }
  55. }
Add Comment
Please, Sign In to add comment