@@ -7,8 +7,9 @@ $.widget( "ui.grid", {
7
7
options : { } ,
8
8
_create : function ( ) {
9
9
10
- var totalWidth = 0 ,
11
- colWidths = this . element . find ( "td:eq(0)" ) . parent ( "tr" ) . children ( ) . map ( function ( ) {
10
+ var _this = this ,
11
+ totalWidth = 0 ,
12
+ colWidths = this . element . find ( "td:eq(0)" ) . parent ( "tr" ) . children ( ) . map ( function ( ) {
12
13
var width = $ ( this ) . outerWidth ( ) ;
13
14
totalWidth += width
14
15
return width ;
@@ -36,45 +37,49 @@ $.widget( "ui.grid", {
36
37
. appendTo ( uiGridBody ) ;
37
38
38
39
// Move table CAPTION to grid head
39
- uiGridBodyTable . find ( "caption" )
40
+ uiGridBodyTable . find ( "caption" )
40
41
. prependTo ( uiGridHeadTable ) ;
41
42
42
43
// Create COLGROUP and COLs if missing
43
44
if ( ! uiGridBodyTable . find ( "colgroup" ) . length ) {
44
45
// TODO: Consider adding support for existing COL elements not inside COLGROUP
45
46
// TODO: ... in the meantime, remove any that might exist
46
- uiGridBodyTable . find ( "col" ) . remove ( ) ;
47
- var colgroup = $ ( "<colgroup></colgroup>" ) . insertBefore ( uiGridBodyTable . find ( "thead" ) ) ;
48
- uiGridBodyTable . find ( "tr:eq(0)" ) . children ( ) . each ( function ( i ) {
49
- colgroup . append ( "<col>" ) ;
47
+ uiGridBodyTable . find ( "col" ) . remove ( ) ;
48
+ var colgroup = $ ( "<colgroup></colgroup>" ) . insertBefore ( uiGridBodyTable . find ( "thead" ) ) ;
49
+ uiGridBodyTable . find ( "tr:eq(0)" ) . children ( ) . each ( function ( i ) {
50
+ colgroup . append ( "<col>" ) ;
50
51
} ) ;
51
52
}
52
53
53
54
// Auto-size columns based on relative widths of pre-grid table column widths
54
- uiGridBody . find ( "colgroup" ) . children ( ) . each ( function ( i ) {
55
- $ ( this ) . css ( "width" , ( colWidths [ i ] / totalWidth * 100 ) + '%' ) ;
55
+ uiGridBody . find ( "colgroup" ) . children ( ) . each ( function ( i ) {
56
+ $ ( this ) . css ( "width" , ( colWidths [ i ] / totalWidth * 100 ) + '%' ) ;
56
57
} ) ;
57
58
58
59
// Copy table COLGROUP to grid head
59
- uiGridBodyTable . find ( "colgroup" )
60
+ uiGridBodyTable . find ( "colgroup" )
60
61
. clone ( )
61
62
. appendTo ( uiGridHeadTable ) ;
62
63
63
64
// Move table THEAD to grid head for fixed column headers
64
- uiGridBodyTable . find ( "thead" )
65
+ uiGridBodyTable . find ( "thead" )
65
66
. appendTo ( uiGridHeadTable ) ;
66
67
67
68
// Give head rows a clickable state
68
- uiGridHeadTable . find ( "tr" ) . addClass ( "ui-state-default" ) ;
69
+ uiGridHeadTable . find ( "tr" ) . addClass ( "ui-state-default" ) ;
69
70
70
71
// Give head cells a clickable state
71
72
this . _hoverable ( uiGridHeadTable . find ( "th" ) . addClass ( "ui-state-default" ) ) ;
72
73
73
74
// Give body rows a clickable state
74
- uiGridBodyTable . find ( "tr" ) . addClass ( "ui-state-default" ) ;
75
+ uiGridBodyTable . find ( "tr" ) . addClass ( "ui-state-default" ) ;
75
76
76
77
// Give body cells a clickable state
77
- uiGridBodyTable . find ( "td" ) . addClass ( "ui-state-default" ) ;
78
+ uiGridBodyTable . find ( "td" ) . addClass ( "ui-state-default" ) ;
79
+
80
+ uiGrid . bind ( "resize" , function ( ) {
81
+ _this . refresh ( ) ;
82
+ } ) ;
78
83
79
84
this . refresh ( ) ;
80
85
@@ -89,6 +94,15 @@ $.widget( "ui.grid", {
89
94
headHeight = this . uiGridHead . height ( ) ,
90
95
footHeight = this . uiGridFoot . height ( ) ;
91
96
97
+ if ( this . uiGrid . is ( ":ui-resizable" ) ) {
98
+ this . uiGrid . addClass ( "ui-grid-resizable" ) ;
99
+ if ( footHeight < 16 ) {
100
+ footHeight = this . uiGridFoot . height ( 16 ) ;
101
+ }
102
+ } else {
103
+ this . uiGrid . removeClass ( "ui-grid-resizable" ) ;
104
+ }
105
+
92
106
// Adjust body height to fill
93
107
this . uiGridBody . height ( gridHeight - headHeight - footHeight ) ;
94
108
0 commit comments