When using gridpanel, we sometimes need to set autoheight: true. However, if the table width is greater than the container width, the excess content will be hidden without a horizontal scroll bar, the solution was found only after the boss tried to add the following attributes to the option config of gridpanel:
Viewconfig :{
- Layout: function (){
- If (! This. mainbody ){
- Return; // not rendered
- }
- VaR G = This. grid;
- VaR c = G. getgridel ();
- VaR csize = C. getsize (true );
- VaR vw = csize. width;
- If (! G. hideheaders & (VW <20 | csize. height <20) {// display:
- // None?
- Return;
- }
- If (G. autoheight ){
- This. El. Dom. style. width = "100% ";
- This. El. Dom. style. Overflow = "Auto ";
- This. El. Dom. firstchild. style. Overflow = "visible ";
- This.el.dom.firstchild.style.css float = "Left ";
- This.el.dom.firstchild.firstchild.style.css float = "Left ";
- This.el.dom.firstchild.firstchild.nextsibling.style.css float = "Left ";
- This. El. Dom. firstchild. style. Overflow = "visible ";
- This. El. Dom. firstchild. firstchild. nextsibling. style. Overflow = "visible ";
- } Else {
- This. El. setsize (csize. Width, csize. Height );
- VaR hdheight = This. mainhd. getheight ();
- VaR VL = csize. Height-(hdheight );
- This. scroller. setsize (VW, VL );
- If (this. innerhd ){
- This. innerhd. style. width = (VW) + 'px ';
- }
- }
- If (this. forcefit ){
- If (this. lastviewwidth! = VW ){
- This. fitcolumns (false, false );
- This. lastviewwidth = VW;
- }
- } Else {
- This. autoexpand ();
- This. syncheaderscroll ();
- }
- This. onlayout (VW, FLAC );
- }
- }
Viewconfig: {<br/> layout: function () {<br/> If (! This. mainbody) {<br/> return; // not rendered <br/>}< br/> var G = This. GRID; <br/> var c = G. getgridel (); <br/> var csize = C. getsize (true); <br/> var vw = csize. width; <br/> If (! G. hideheaders & (VW <20 | csize. height <20) {// display: <br/> // none? <Br/> return; <br/>}< br/> If (G. autoheight) {<br/> This. el. dom. style. width = "100%"; <br/> This. el. dom. style. overflow = "Auto"; <br/> This. el. dom. firstchild. style. overflow = "visible"; <br/> this.el.dom.firstchild.style.css float = "Left"; <br/> define float = "Left"; <br/> define float = "Left "; <br/> This. el. dom. firstchi LD. firstchild. firstchild. style. overflow = "visible"; <br/> This. el. dom. firstchild. firstchild. nextsibling. style. overflow = "visible"; <br/>} else {<br/> This. el. setsize (csize. width, csize. height); <br/> var hdheight = This. mainhd. getheight (); <br/> var VL = csize. height-(hdheight); <br/> This. scroller. setsize (VW, VL); <br/> If (this. innerhd) {<br/> This. innerhd. style. width = (VW) + 'px '; <br/>}< br/>} <Br/> If (this. forcefit) {<br/> If (this. lastviewwidth! = VW) {<br/> This. fitcolumns (false, false); <br/> This. lastviewwidth = VW; <br/>}< br/>} else {<br/> This. autoexpand (); <br/> This. syncheaderscroll (); <br/>}< br/> This. onlayout (VW, FLAC); <br/>}< br/>
Many problems have been encountered during the solution, such as incomplete background of the header, not all columns can be resize (resizable: True has been set), so there may be many problems I have not found. If anyone finds any problems, I hope you can give me some advice.
Modify:
Another simple method is found to be much better than the above method.
[JavaScript]
View plaincopyprint?
- Viewconfig :{
- Layout: function (){
- If (! This. mainbody ){
- Return; // not rendered
- }
- VaR G = This. grid;
- VaR c = G. getgridel ();
- VaR csize = C. getsize (true );
- VaR vw = csize. width;
- If (! G. hideheaders & (VW <20 | csize. height <20) {// display:
- // None?
- Return;
- }
- If (G. autoheight ){
- If (this. innerhd ){
- This. innerhd. style. width = (VW) + 'px ';
- }
- } Else {
- This. El. setsize (csize. Width, csize. Height );
- VaR hdheight = This. mainhd. getheight ();
- VaR VL = csize. Height-(hdheight );
- This. scroller. setsize (VW, VL );
- If (this. innerhd ){
- This. innerhd. style. width = (VW) + 'px ';
- }
- }
- If (this. forcefit ){
- If (this. lastviewwidth! = VW ){
- This. fitcolumns (false, false );
- This. lastviewwidth = VW;
- }
- } Else {
- This. autoexpand ();
- This. syncheaderscroll ();
- }
- This. onlayout (VW, FLAC );
- }
- }