// // SearchFilterViewController.m // RedAnt ERP Mobile // // Created by Ray on 14-7-25. // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved. // #import "SearchFilterViewController.h" #import "FilterCellCadedate.h" #import "FilterCellValue.h" @interface SearchFilterViewController () @end @implementation SearchFilterViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Close", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCloseClick:)]; self.navi_item.rightBarButtonItem = closeButton; // Do any additional setup after loading the view. } - (void)onCloseClick:(UIButton *)sender { [self dismissViewControllerAnimated:YES completion:^{ }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)onSwitchTap:(UISwitch *)sender { // UIView* sectionheader = sender.superview; int section = sender.superview.tag; if(section == 0 ) return; for(int i=0;i<[[self.cadedate valueForKey:@"groups"]intValue];i++) { NSMutableDictionary* group_json = [[self.cadedate objectForKey:[NSString stringWithFormat:@"group_%d",i ]] mutableCopy]; if(i==section-1) { if(sender.on) { [group_json setValue:@1 forKey:@"multi_select"]; } else { [group_json setValue:@0 forKey:@"multi_select"]; int count = [[group_json valueForKey:@"count"]intValue]; for(int j=0;j=1) title=[title substringToIndex:title.length-1]; [value_group_json setValue:title forKey:@"title"]; [value_group_json setValue:@(check_count) forKey:@"count" ]; [value_group_json setValue:key forKey:@"key" ]; [value_json setObject:value_group_json forKey:[NSString stringWithFormat:@"group_%d",groups]]; self.value = value_json; // NSError *error = nil; // NSData *jsonData = [NSJSONSerialization dataWithJSONObject:value_json // options:NSJSONWritingPrettyPrinted // error:&error]; // // // // NSData * d = [NSData alloc] initwithd // NSString *result = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; // NSLog(result); [self closewindow]; } - (IBAction)OnDeleteValue:(UIButton *)sender { int groups = [[self.value valueForKey:@"groups"]intValue]; if(groups==1) { self.value = nil; [self closewindow]; } else { FilterCellValue *cell = (FilterCellValue *) sender.superview.superview.superview; // NSIndexPath* indexPath = [self.tableView indexPathForCell:cell]; NSMutableDictionary * value_json=[[NSMutableDictionary alloc] init]; int count = 0; for(int i=0;i