6

Sorry, I know this is a bit complicated question .

Life is easy when I want to make a NSTableview object on screen with fixed number of columns. I just make a data binding to each column and simply read/write to that model (according to MVC).

But life gets unkind when I need a table with dynamic column number ( I mean user is allowed to add/ remove columns) . By the time I have used 2 different approaches: In first and easier , but worst approach I can make a table big enough , such that user can never fill it up !. but I know the memory would never appreciate that !!

In second approach , I can make an array of NSTableColumn and assign a numbered identifier to each column like this:

NSTableColumn * column[iColumn]; //NSInteger iColumn is defined by user

   for( int i=0;i< iColumn;i++){
        column[i] = [[NSTableColumn alloc] initWithIdentifier:[ NSString stringWithFormat:@"%i" ,i] ];
        [column[i] setWidth:100];
        [tableView   addTableColumn:column[i]];
    }

This works fine, but there are some annoying limitations to that .for example using "Data binding " and using some drag&drops is so much easier than handling a table with columns numbered as 1,2,3,.... programatically .

I think to myself there must be some easier way to use UI Builder for this purpose rather than writing codes.Perhaps it may be possible to bind data for whole TableView rather than for each individual column ( something like what is available in Visual Studio C++/Clr for "dataTable" object. Or another method ? Any answer would be kindly appreciated

Community
  • 1
  • 1
Aug
  • 595
  • 9
  • 22
  • A table big enough...? Why not just put the table view in a scroll view. – TheAmateurProgrammer Sep 19 '12 at 13:50
  • Sorry, but I couldn't get the solution. I think tableView is in a scrollView by default. Can you explain a little more please? – Aug Sep 19 '12 at 15:12
  • What data will be bound to these new columns? Do you have many fields (or keys in a dictionary or attributes in an entity) that are in your original data but not bound to anything in your table view, or is the user somehow adding more fields of data also. – rdelmar Sep 19 '12 at 15:47
  • User can add any number of columns and enter it's own data ( String , or numbers) to them. Then all these data is transferred to a SQLite database for further processing. – Aug Sep 19 '12 at 18:07
  • i would need the same thing. did you find an answer? – sharkyenergy Feb 01 '13 at 21:36

0 Answers0