Add extra row in tableview for CouchUITableSource

82 views
Skip to first unread message

Sangam Angre

unread,
Jan 30, 2013, 5:35:06 AM1/30/13
to mobile-c...@googlegroups.com
I want to display additional row in tableview. Lets say am having 2 entries in my couchtable i want to display 3 rows on UI.

I am using this function for Cell display:
- (UITableViewCell *) couchTableSource : (CouchUITableSource*) source
                 cellForRowAtIndexPath : (NSIndexPath *) indexPath


How should I return count in UItableVIew's delegate "numberOfRowsInSection"?
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [data count];
}

I am totally newbie to Couchbase.

Pulkit Singhal

unread,
Jan 30, 2013, 10:37:51 AM1/30/13
to mobile-c...@googlegroups.com
One way to do this is to populate a false document in your DB ... for which you can then construct the cell differently ... but I don't like the notion of false data because it can be deleted by the user and if your row was some sort of an action, it will screw it up for later.

You could move the row that functionally takes some sort of an action ... to the top of your view to site there all alone and then have another TableView which is separately controlled by CouchUITableSource ... but again its a bit of a hack?

Maybe someone else will have better advise.

Jens Alfke

unread,
Jan 30, 2013, 12:00:42 PM1/30/13
to mobile-c...@googlegroups.com

On Jan 30, 2013, at 2:35 AM, Sangam Angre <sangam...@techanveshan.com> wrote:

I want to display additional row in tableview. Lets say am having 2 entries in my couchtable i want to display 3 rows on UI.

That’s not something CouchUITableSource supports. But you can do it yourself — CouchUITableSource is really just a convenience class for a common use case. You can copy its source code, rename the class, and modify it to do what you want. In your case, I think I’d modify the -reloadFromQuery method and add an extra item to _rows (although that’d be a little bit messy because there’s no public initializer for CouchQueryRow, so your extra item would need to be some other class…)

—Jens

Pulkit Singhal

unread,
Feb 3, 2013, 9:48:54 AM2/3/13
to mobile-c...@googlegroups.com
One way to do this is to populate a false document in your DB ... for which you can then construct the cell differently ... but I don't like the notion of false data because it can be deleted by the user and if your row was some sort of an action, it will screw it up for later.

Here's a issue I opened to make sure that the "screw-up" doesn't happen:
https://github.com/couchbaselabs/CouchCocoa/issues/63

It has the patch url in it:
https://gist.github.com/4702055

Jens, would you be willing to accept this as an enhancement to the out-of-box CouchUITableSource ... please!

- Pulkit

Karel-Jan Van Haute

unread,
Oct 28, 2014, 11:02:24 AM10/28/14
to mobile-c...@googlegroups.com
Hey Sangam

have you ever fixed this?

thanks
Karel-Jan

Jens Alfke

unread,
Oct 28, 2014, 1:42:26 PM10/28/14
to mobile-c...@googlegroups.com
I think this is one of those cases where you'll need to modify CBLUITableSource or write your own table data source. It's a utility class that's intended to handle the most common tasks of driving a table view from a CBL view, but it doesn't handle every possible need.

The code is pretty straightforward. If you modify it, make sure to change the class name to avoid conflicts.

—Jens
Reply all
Reply to author
Forward
0 new messages