UA-17470720-3

Jump to content


Photo
- - - - -

how to reload a selection cell?

cells sections actions

  • Please log in to reply
4 replies to this topic

#1 Balachandhar

Balachandhar

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 87 posts
Reputation: 21
Excellent

Posted 03 May 2013 - 05:40 PM

Hi,

I am trying to reload a cell with list of strings that is for selection cell. below is the code snippet which i am using, kindly help me by giving some code snippet.

thanks,
bala


SCEntityDefinition *matterdef = [SCEntityDefinition definitionWithEntityName:@"Matter" managedObjectContext:self.appDelegate.managedObjectContext propertyNamesString:@"mattername;filenumber;mratetype;desc;opendate;closedate;status;practicearea;slips;tasks;notes"];
SCPropertyDefinition *matterNamePropDef = [notedef propertyDefinitionWithName:@"mattername"];
matterNamePropDef.title = @"Matter Name";
SCPropertyDefinition *mRateTypePropDef = [matterdef propertyDefinitionWithName:@"mratetype"];
mRateTypePropDef.title = @"Billing Rate Type";
mRateTypePropDef.type = SCPropertyTypeSelection;
NSArray *mrateItems = [NSArray arrayWithObjects:@"Staff Rates",
@"Matter Rates", @"Non-Billable", nil];

mRateTypePropDef.attributes = [SCSelectionAttributes
attributesWithItems:mrateItems allowMultipleSelection:NO
allowNoSelection:NO];
//
SCPropertyDefinition *matterdescPropDef = [matterdef propertyDefinitionWithName:@"desc"];
matterdescPropDef.type = SCPropertyTypeTextView;
matterdescPropDef.title = @"Description";
SCPropertyDefinition *openDatePropDef = [matterdef propertyDefinitionWithName:@"opendate"];
openDatePropDef.type = SCPropertyTypeDate;
openDatePropDef.title = @"Open Date";
SCPropertyDefinition *closeDatePropDef = [matterdef propertyDefinitionWithName:@"closedate"];
closeDatePropDef.type = SCPropertyTypeDate;
closeDatePropDef.title = @"Close Date";
SCPropertyDefinition *filenumPropDef = [matterdef propertyDefinitionWithName:@"filenumber"];
// filenumPropDef.type = SCPropertyTypeTextView;
filenumPropDef.required = TRUE;
filenumPropDef.title = @"File Number";

SCPropertyDefinition *statusSelectionPropDef = [matterdef propertyDefinitionWithName:@"status"];
statusSelectionPropDef.type = SCPropertyTypeSelection;
statusSelectionPropDef.title = @"Status";
NSArray *statusItems = [NSArray arrayWithObjects:@"Open",
@"Closed", @"Pending", nil];

statusSelectionPropDef.attributes = [SCSelectionAttributes
attributesWithItems:statusItems allowMultipleSelection:NO
allowNoSelection:NO];


SCPropertyDefinition *practiceAreaSelectionPropDef = [matterdef propertyDefinitionWithName:@"practicearea"];
practiceAreaSelectionPropDef.type = SCPropertyTypeSelection;
practiceAreaSelectionPropDef.title = @"Practice Area";
practiceAreaSelectionPropDef.attributes = [SCSelectionAttributes
attributesWithItems:[practiceAreaDict allValues] allowMultipleSelection:NO
allowNoSelection:NO];
practiceAreaSelectionPropDef.cellActions.willConfigure = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
workAreaCell=cell;
};

SMCustomCodeRequest *practice_areaRequest = [[SMCustomCodeRequest alloc]
initGetRequestWithMethod:@"practice_area"];

[[[SMClient defaultClient] dataStore] performCustomCodeRequest:practice_areaRequest onSuccess:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {

NSLog(@"Success: %@",JSON);

practiceAreaDict = JSON;

//
practiceAreaSelectionPropDef.attributes = [SCSelectionAttributes
attributesWithItems:[JSON allValues] allowMultipleSelection:NO
allowNoSelection:NO];
//

[self.tableViewModel reloadBoundValues];
[self.tableViewModel.modeledTableView reloadData];


/* NSIndexPath *indexPath = [self.tableView indexPathForCell:workAreaCell];

// Reload the cell; do not animate the reload.
NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
[self.tableViewModel.tableView reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];*/

practiceAreaSelectionPropDef.cellActions.willConfigure = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
NSLog(@"cell reloaded...");
};

} onFailure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON){
NSLog(@"Failure: %@",error);
}];






SCPropertyDefinition *responsibleattorneyPropertyDef = [matterdef propertyDefinitionWithName:@"responsibleattorney"];
responsibleattorneyPropertyDef.type = SCPropertyTypeObject;
responsibleattorneyPropertyDef.attributes = [SCObjectAttributes attributesWithObjectDefinition:userdef];

SCPropertyDefinition *slipsPropertyDef = [matterdef propertyDefinitionWithName:@"slips"];
slipsPropertyDef.attributes = [SCArrayOfObjectsAttributes attributesWithObjectDefinition:slipdef allowAddingItems:TRUE allowDeletingItems:TRUE allowMovingItems:FALSE];

SCPropertyDefinition *tasksPropertyDef = [matterdef propertyDefinitionWithName:@"tasks"];
tasksPropertyDef.attributes = [SCArrayOfObjectsAttributes attributesWithObjectDefinition:taskdef allowAddingItems:TRUE allowDeletingItems:TRUE allowMovingItems:FALSE];

SCPropertyDefinition *notesPropertyDef = [matterdef propertyDefinitionWithName:@"notes"];
notesPropertyDef.attributes = [SCArrayOfObjectsAttributes attributesWithObjectDefinition:notedef allowAddingItems:TRUE allowDeletingItems:TRUE allowMovingItems:FALSE];


matter = [NSEntityDescription insertNewObjectForEntityForName:@"Matter" inManagedObjectContext:self.appDelegate.managedObjectContext];

[self.doneButton setAction:@selector(save:)];
[self.tableViewModel generateSectionsForObject:matter withDefinition:matterdef newObject:YES];
  • gfdhzt6t likes this

#2 wizgod

wizgod

    I'm what you guys call a User

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 575 posts
  • LocationThe Grid
Reputation: 149
Popular

Posted 03 May 2013 - 08:43 PM

So you're trying to retrieve the data from the web service call after the cell has displayed and then change the attributes and refresh it?

Like in my PM, I've never added an action to a def so I don't know what the result is; try replacing with practiceAreaSelectionPropDef.cellActions with self.tableViewModel.cellActions.

Would it work if you grabbed the data from the web service before you did the entity definition?

Wg

P.S. I love Swift... talk Swift.. Never too old school to learn yet another programming language. LOL! ;-)


#3 Balachandhar

Balachandhar

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 87 posts
Reputation: 21
Excellent

Posted 06 May 2013 - 07:50 PM

yes, initially i am trying to load the tableview. and retrieving data from service, after the service call i want to reload particular cell with retrieved data.  

 

can you give me code snippet for this? i tried  self.tableViewModel.cellActions instead of practiceAreaSelectionPropDef.cellActions but no luck.

 

Thanks,

bala



#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 08 May 2013 - 01:35 PM

Hi bala,

 

I don't see you updating the SCSelectionCell items anywhere in your code, am I missing something here? Perhaps you need something similar to this post: http://sensiblecocoa...erty/#entry9047



#5 Balachandhar

Balachandhar

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 87 posts
Reputation: 21
Excellent

Posted 15 May 2013 - 11:15 AM

hi Tarek,

 

here i am trying to reload the cell, if this is wrong then give me the code snippet - please.

 

SMCustomCodeRequest *practice_areaRequest = [[SMCustomCodeRequest alloc]
initGetRequestWithMethod:@"practice_area"];
[[[SMClient defaultClient] dataStore] performCustomCodeRequest:practice_areaRequest onSuccess:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
practiceAreaDict = JSON;
//
practiceAreaSelectionPropDef.attributes = [SCSelectionAttributes
attributesWithItems:[JSON allValues] allowMultipleSelection:NO
allowNoSelection:NO];
//
[self.tableViewModel reloadBoundValues];
[self.tableViewModel.modeledTableView reloadData];







Also tagged with one or more of these keywords: cells, sections, actions

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users