From 31a9b3b3510d15a5bb8820629eee20bb1303fa16 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 13 May 2018 03:10:07 +0200 Subject: Fix the issue with the advanced filter table not being usable for tables with many columns --- Source/SPFilterTableController.m | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Source') diff --git a/Source/SPFilterTableController.m b/Source/SPFilterTableController.m index dc1bf98a..60e67a04 100644 --- a/Source/SPFilterTableController.m +++ b/Source/SPFilterTableController.m @@ -165,6 +165,7 @@ static void *FilterTableKVOContext = &FilterTableKVOContext; [self setFilterError:0 message:nil sqlstate:nil]; if(dataColumns) { + CGFloat totalWidth = 0; // Add the new columns to the filterTable for (NSDictionary *columnDefinition in dataColumns ) { // Set up column for filterTable @@ -175,6 +176,10 @@ static void *FilterTableKVOContext = &FilterTableKVOContext; [filterDataCell setEditable:YES]; [filterDataCell setLineBreakMode:NSLineBreakByTruncatingTail]; // add ellipsis for long values (default is to simply hide words) [filterCol setDataCell:filterDataCell]; + NSSize headerSize = [[[filterCol headerCell] attributedStringValue] size]; + CGFloat headerInitialWidth = headerSize.width + 5.0; + [filterCol setWidth:headerInitialWidth]; + totalWidth += headerInitialWidth; [filterTableView addTableColumn:filterCol]; [filterCol release]; @@ -184,6 +189,9 @@ static void *FilterTableKVOContext = &FilterTableKVOContext; [NSMutableArray arrayWithObjects:@"", @"", @"", @"", @"", @"", @"", @"", @"", @"", nil], SPTableContentFilterKey, nil] forKey:[columnDefinition objectForKey:@"datacolumnindex"]]; } + + // 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 + if(totalWidth < [[filterTableView enclosingScrollView] contentSize].width) [filterTableView sizeToFit]; } [filterTableView reloadData]; -- cgit v1.2.3