Skip to content

Commit 31a9b3b

Browse files
committed
Fix the issue with the advanced filter table not being usable for tables with many columns
1 parent 375faa0 commit 31a9b3b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Interfaces/English.lproj/FilterTableWindow.xib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<rect key="frame" x="0.0" y="23" width="752" height="119"/>
5252
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
5353
<subviews>
54-
<tableView identifier="AdvancedFilterTableView" verticalHuggingPriority="750" allowsExpansionToolTips="YES" selectionHighlightStyle="sourceList" alternatingRowBackgroundColors="YES" emptySelection="NO" autosaveColumns="NO" headerView="eWi-Z3-2Sr" id="8SC-Fh-D9L" customClass="SPCopyTable">
54+
<tableView identifier="AdvancedFilterTableView" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" selectionHighlightStyle="sourceList" alternatingRowBackgroundColors="YES" emptySelection="NO" autosaveColumns="NO" headerView="eWi-Z3-2Sr" id="8SC-Fh-D9L" customClass="SPCopyTable">
5555
<rect key="frame" x="0.0" y="0.0" width="752" height="119"/>
5656
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
5757
<size key="intercellSpacing" width="3" height="2"/>
@@ -240,7 +240,7 @@
240240
<action selector="toggleLookAllFieldsMode:" target="-2" id="S7l-Cy-VFb"/>
241241
</connections>
242242
</button>
243-
<button toolTip="Clear all Filter Criterias (⌘⌫)" verticalHuggingPriority="750" id="egJ-46-zsK">
243+
<button toolTip="Clear all Filter Criteria (⌘⌫)" verticalHuggingPriority="750" id="egJ-46-zsK">
244244
<rect key="frame" x="452" y="12" width="143" height="32"/>
245245
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
246246
<buttonCell key="cell" type="push" title="Clear" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="0Ec-f2-4N5">

Source/SPFilterTableController.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ - (void)setColumns:(NSArray *)dataColumns
165165
[self setFilterError:0 message:nil sqlstate:nil];
166166

167167
if(dataColumns) {
168+
CGFloat totalWidth = 0;
168169
// Add the new columns to the filterTable
169170
for (NSDictionary *columnDefinition in dataColumns ) {
170171
// Set up column for filterTable
@@ -175,6 +176,10 @@ - (void)setColumns:(NSArray *)dataColumns
175176
[filterDataCell setEditable:YES];
176177
[filterDataCell setLineBreakMode:NSLineBreakByTruncatingTail]; // add ellipsis for long values (default is to simply hide words)
177178
[filterCol setDataCell:filterDataCell];
179+
NSSize headerSize = [[[filterCol headerCell] attributedStringValue] size];
180+
CGFloat headerInitialWidth = headerSize.width + 5.0;
181+
[filterCol setWidth:headerInitialWidth];
182+
totalWidth += headerInitialWidth;
178183
[filterTableView addTableColumn:filterCol];
179184
[filterCol release];
180185

@@ -184,6 +189,9 @@ - (void)setColumns:(NSArray *)dataColumns
184189
[NSMutableArray arrayWithObjects:@"", @"", @"", @"", @"", @"", @"", @"", @"", @"", nil], SPTableContentFilterKey,
185190
nil] forKey:[columnDefinition objectForKey:@"datacolumnindex"]];
186191
}
192+
193+
// if the width of all columns is still less than the width of the table view resize them uniformly once to take up all horizontal space
194+
if(totalWidth < [[filterTableView enclosingScrollView] contentSize].width) [filterTableView sizeToFit];
187195
}
188196

189197
[filterTableView reloadData];

0 commit comments

Comments
 (0)