Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to not show sections in table #3

Open
lgadams opened this issue Nov 2, 2011 · 4 comments
Open

How to not show sections in table #3

lgadams opened this issue Nov 2, 2011 · 4 comments
Assignees

Comments

@lgadams
Copy link

lgadams commented Nov 2, 2011

Hi Xenofex,

I have been playing around with the grid and have been trying to find an easy way to not use sections.

What I have come up with, which I think needs some work is something like this:

In your example, I have modified viewDidLoad in MultiColumnTableViewController.m to look like this:

- (void)viewDidLoad
{
[super viewDidLoad];
    numberOfColumns = 5;
    numberOfRows = 30;
    numberOfSections = 1;

    colWidth = 240.0f;
    headerHeight = 100;
    headerWidth = colWidth;

    data = [[NSMutableArray alloc] initWithCapacity:numberOfRows];

    for (int i = 0; i < numberOfRows; i++) 
    {        
            NSMutableArray *rowArray = [NSMutableArray arrayWithCapacity:numberOfColumns];
            for (int j = 0; j < numberOfColumns; j++) {
                [rowArray addObject:text];
            }

            //[sectionArray addObject:rowArray];
        [data addObject:rowArray];        
    }


    tblView = [[EWMultiColumnTableView alloc] initWithFrame:CGRectInset(self.view.bounds, 5.0f, 5.0f)];
//    tblView.sectionHeaderEnabled = YES;
//    tblView.cellWidth = 100.0f;
//    tblView.boldSeperatorLineColor = [UIColor blueColor];
//    tblView.normalSeperatorLineColor = [UIColor blueColor];
//    tblView.boldSeperatorLineWidth = 10.0f;
//    tblView.normalSeperatorLineWidth = 10.0f;
    tblView.dataSource = self;
    tblView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    [self.view addSubview:tblView];
}

and modified this method to just return the number of rows…

- (NSInteger)tableView:(EWMultiColumnTableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [data count];
}

Is there an easier and more readable way to not use sections and just have pure rows in the grid? I couldn't really see any other way with out extending the API a bit...

Also, is there a more dynamic way to calculate the width/height of the columns rather than hard coding them? Sorry I am new to iOS programming.

Thanks!

@Xenofex
Copy link
Owner

Xenofex commented Nov 3, 2011

Hi, Igadams

Is there an easier and more readable way to not use sections and just have pure rows in the grid?

Just set sectionHeaderEnabled = NO, as that in your code, you commented out
the line to set this value to YES. This property is NO by default

Also, is there a more dynamic way to calculate the width/height of the columns rather than hard coding them?

Definitely there are. Looking into the file EWMultiColumnTableView.h, you'll find that there are many delegate methods which can configure the grid. In your case here,

- (CGFloat)tableView:(EWMultiColumnTableView *)tableView heightForCellAtIndexPath:(NSIndexPath *)indexPath 
        column:(NSInteger)column;

- (CGFloat)tableView:(EWMultiColumnTableView *)tableView widthForColumn:(NSInteger)column;

the 2 methods do exactly what you want.

Maybe you are not familiar with the original UITableView. This multi-column table view is designed working in the same way of the original UITableView. You implement some required delegate methods, then you got the basic layout. If you want it more customizable, just implement more.

@lgadams
Copy link
Author

lgadams commented Nov 3, 2011

Hi Xenofex,

For the sections issue... looks like I need to update this function to be something like this:

- (NSInteger)tableView:(EWMultiColumnTableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if(tableView.sectionHeaderEnabled == NO)
        return [data count];
    else
        return [[data objectAtIndex:section] count];
}

I also didn't realize if I didn't implement numberOfSectionsInTableView() in MultiColumnTableViewViewController.m the correct number of rows are returned correctly.

I had another question for you about the grid. Is there away to have a different number of columns on each row in the grid? The current application I am working on has column spans that will span the entire grid.

@Xenofex
Copy link
Owner

Xenofex commented Nov 4, 2011

For this question:

- (NSInteger)tableView:(EWMultiColumnTableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView.sectionHeaderEnabled == NO)
        return [data count];
    else
        return [[data objectAtIndex:section] count];
}

So you want a grid with out sections. Then you just have one section there and set sectionHeaderEnabled == NO. And if you don't implement

- (NSInteger)numberOfSectionsInTableView:(EWMultiColumnTableView *)tableView;

the number of sections will be 1, similar as the UITableView

For the column spaning, currently it doesn't support. I'll think about a quick way to implement this. For now if you set only the width of some column to be wide enough to span across columns, the vertical table line will be above of it.

@ghost ghost assigned Xenofex Nov 11, 2011
@vickydhas
Copy link

Is there is any possibility to span columns on top so its like a common col span for multiple rows below.

Take an example that the left item rows are fixed and right side are as follows

Months Column span cell for below rows Jan - Dec then next 2 columns header is spanned as 1 on first row.

When i scroll up the first two should remain on top and when i scroll left the entire spanned header row 1 and 2nd sub columns are scrolled left.

screen shot 2014-09-26 at 7 03 02 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants