Yesterday I wanted to implement button permission control on the front-end (using extjs). The front-end button permission control itself is not secure and will not be discussed for the moment.
Ext. the findbytype method of the container cannot obtain any types of controls in the lower-level of the container. For example, the get button cannot obtain the buttons in the toolbar of the Panel. Therefore, I want to create a findbytype method myself.
You can use the following method to obtain all the buttons in a container.
// Defines Ext. NS ("TT. util "); Ext. NS ("TT. data "); TT. data. btnarray = NULL; // get all the buttons in the current container TT. util. findbtnbase = function (c) {var array = []; If (C. toolbars) {Ext. each (C. toolbars, function (I) {var J = I. items. items; Ext. each (J, function (k) {If (K. xtype = 'button '| K. type = 'button ') {array. push (k) ;}})});} If (C. items & C. items. items) {var I = C. items. items; Ext. each (I, function (j) {If (J. xtype = 'button '| j. type = 'button ') {array. push (j) ;}}) ;}return array ;}// get all the buttons of the current container and all lower-level containers (recursion) TT. util. findbtn = function (c) {// If C is not a leaf node if (C. items & C. items. items) | (C. toolbars) {var btnarray = TT. util. findbtnbase (c); TT. util. pusharray (btnarray, TT. data. btnarray); If (C. items & C. items. items) {Ext. each (C. items. items, function (I) {TT. util. findbtn (I) ;}}}// extract the contents of the SRC array into the Dest array TT. util. pusharray = function (SRC, DEST) {Ext. each (SRC, function (I) {DeST. push (I );});}