Welcome, Guest
Username Password: Remember me

Automatic completions of cells based upon selected criteria
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: Automatic completions of cells based upon selected criteria

Automatic completions of cells based upon selected criteria 1 year, 4 months ago #1

Evening

Is it possible that when you pick a selection from a cell that other cells can be populated based upon the selection.

For example, if I pick Apple, the other cells such a Fruit or Vegetable, Shape would be automatically completed.

I understand that I would need to create the values but what to see if this has been done using STV.

Regards

Iain
  • ihmunro
  • OFFLINE
  • Expert Boarder
  • Posts: 135
  • Karma: 0

Re: Automatic completions of cells based upon selected criteria 1 year, 4 months ago #2

Hi Iain,

STV lets you detect when a new selection has occurred, and gives you access to the value of this selection. From there, you can do anything you want. Here is some sample code:

 
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
valueChangedForRowAtIndexPath:(NSIndexPath *)indexPath
{
SCTableViewCell *cell = [tableViewModel cellAtIndexPath:indexPath];
if([cell isKindOfClass:[SCSelectionCell class]])
{
SCSelectionCell *selectionCell = (SCSelectionCell *)cell;
NSInteger selectedIndex = [selectionCell.selectedItemIndex intValue];
 
// your code here
...
}
}
 
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Automatic completions of cells based upon selected criteria 1 year, 4 months ago #3

Hi,

I was working on a quite similar problem as lain and thankfully found this thread.

My only problem is that the valueChangedForRowAtIndexPath method never gets called when I change a value in my selectionCells.

Thanks for any further help,

Gerald
  • gerryka
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Karma: 0

Re: Automatic completions of cells based upon selected criteria 1 year, 4 months ago #4

Hi Gerald,

Are you sure you're conforming to the SCTableViewModelDelegate protocol in your view controller's header file? Also, is your selection cell in the main model, or is it in a detail model?
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Automatic completions of cells based upon selected criteria 1 year, 4 months ago #5

Yes the class is conforming to the protocol.

It is an automatically generated cell that is part of a SCClassDefinition.
 
SCClassDefinition *reportClassDef = [SCClassDefinition definitionWithClass:[ReportObject class]
withPropertyNames:[NSArray arrayWithObjects:@"reportName", @"table",
@"dateFrom", @"dateTo", @"groupBy", nil] withPropertyTitles:[NSArray arrayWithObjects:@"Name",@"Table",@"Start date",@"End date",@"Group by",nil]];
[reportClassDef propertyDefinitionWithName:@"reportName"].required = TRUE;
[reportClassDef propertyDefinitionWithName:@"table"].type = SCPropertyTypeSelection;
[reportClassDef propertyDefinitionWithName:@"table"].attributes = [SCSelectionAttributes attributesWithItems:[[ReportHelper sharedInstance] arrayOfTableNames] allowMultipleSelection:NO allowNoSelection:NO];
 


Thanks for your efforts!
Gerald
  • gerryka
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Karma: 0

Re: Automatic completions of cells based upon selected criteria 1 year, 4 months ago #6

Hi again Gerald,

I'd be happy to have a look at your project if that's ok with you (please send it to our support email). Otherwise, please post your full view controller's STV code so that I would be able to detect/replicate the problem. Thanks!
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72
  • Page:
  • 1
  • 2
Time to create page: 1.82 seconds