Last active
January 1, 2016 20:29
-
-
Save ipreencekmr/8196947 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MytestViewController.m | |
// MyTest | |
// | |
// Created by Prince Kumar Sharma on 02/01/14. | |
// Copyright (c) 2014 Prince Kumar Sharma. All rights reserved. | |
// | |
#import "MytestViewController.h" | |
@interface MytestViewController () | |
@end | |
@implementation MytestViewController | |
- (void)viewDidLoad | |
{ | |
NSArray *headerArray=[[NSArray alloc] initWithObjects:@" -ID- ",@"-Customer Name-",@" Designation ",@" --State-- ",@" -----Address Of Customer---- ",@" --Contact No-- ",@" --Code-- ",@"--total--",nil]; | |
NSArray* firstRow=@[@"234",@"Rohit Sharma",@"Pilot",@"Rajasthan",@"HN-47,Bundi",@"8976565434",@"91",@"0"]; | |
NSArray* secondRow=@[@"578",@"Prakash Aneja",@"Engineer",@"Haryana",@"HN-78,Yamuna Nagar,Jagadhari",@"8976564543",@"12",@"0"]; | |
NSArray *thirdRow=@[@"786",@"Prince Kumar",@"Sofware Engineer",@"Haryana",@"HN-161,Nayapura",@"8976564543",@"32",@"0"]; | |
NSArray *fourthRow=@[@"767",@"Ankit Sharma",@"Civil Engineer",@"Delhi",@"HN-78,Chandani Chowk",@"43238976564",@"98",@"0"]; | |
NSArray *fifth=@[@"767",@"Kush Saxena",@"Chemical Engineer",@"Kolkata",@"HN-67,MG Road",@"7865897656",@"40",@"0"]; | |
NSArray *sixth=@[@"433",@"Piyush Kaushik",@"Mechanical Engineer",@"Chicago",@"HN-763,Sri Apartment",@"2323897656",@"98",@"0"]; | |
dataArray=[[NSMutableArray alloc] initWithArray:@[firstRow,secondRow,thirdRow,fourthRow,fifth,sixth]]; | |
gbTable=[[GridViewTable alloc] initWithFrame:CGRectMake(0, 0, 320, 44) headerArray:headerArray]; | |
gbTable.gtDelegate=self; | |
gbTable.gtDatasource=self; | |
gbTable.autoresizingMask=UIViewAutoresizingFlexibleWidth; | |
[self.view addSubview:gbTable]; | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
} | |
-(void)viewDidAppear:(BOOL)animated | |
{ | |
[gbTable reloadListWithHandler:^(NSInteger gridHeight__) { | |
NSLog(@"height is %i",gridHeight__); | |
}]; | |
} | |
-(NSInteger)numberOfRowsForGridViewTable:(GridViewTable*)gridViewTable | |
{ | |
return [dataArray count]; | |
} | |
-(NSArray*)cellsForRowAtIndex:(int)rowIndex | |
{ | |
return dataArray[rowIndex]; | |
} | |
-(NSInteger)numberOfCellsForRow:(int)rowIndex | |
{ | |
return [dataArray[rowIndex] count]; | |
} | |
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ | |
return YES; | |
} | |
-(CellType)gridViewTable:(GridViewTable*)gridViewTable cellTypeForCellIndex:(int)cellIndex inRow:(int)row | |
{ | |
if (cellIndex==4) { | |
return CTText; | |
} | |
if (cellIndex==5 || cellIndex==6) { | |
return CTNumber; | |
} | |
return CTLabel; | |
} | |
-(NSArray*)gridViewTable:(GridViewTable*)gridViewTable cellIndexArrayForCalculationInRow:(int)row | |
{ | |
return @[@"5",@"6"]; | |
} | |
-(NSInteger)gridViewTable:(GridViewTable*)gridViewTable destinationCellIndexForCalculationInRow:(int)row | |
{ | |
return 7; | |
} | |
-(GridOperation)gridViewTable:(GridViewTable*)gridViewTable operationForCalculationInRow:(int)row | |
{ | |
return Multiply; | |
} | |
-(UIColor*)gridViewTable:(GridViewTable*)gridViewTable colorForCellAtIndex:(int)cellIndex inRow:(int)row | |
{ | |
if (cellIndex==0) { | |
return [UIColor yellowColor]; | |
} | |
if (cellIndex==3) { | |
return [UIColor orangeColor]; | |
} | |
return [UIColor clearColor]; | |
} | |
-(UIColor*)gridViewTable:(GridViewTable *)gridViewTable colorForRowAtIndex:(int)row | |
{ | |
if (row%2==0) { | |
return [UIColor grayColor]; | |
}else{ | |
return [UIColor lightGrayColor]; | |
} | |
} | |
-(UIColor*)colorForHeader | |
{ | |
return [UIColor darkGrayColor]; | |
} | |
-(void)gridViewTable:(GridViewTable*)gridViewTable didSelectRowAtIndex:(NSInteger)row WithSelectedData:(NSDictionary*)selectedRowData | |
{ | |
NSLog(@"selected data at index : %d is : %@",row,selectedRowData); | |
} | |
-(void)inputEditingAtPosition:(NSValue*)point | |
{ | |
int currentYPos=[point CGPointValue].y; | |
NSLog(@"current y pos is %i",currentYPos); | |
} | |
-(void)summationdidCalculated:(NSDictionary*)summation_ | |
{ | |
NSLog(@"summation dictionary is %@",summation_); | |
} | |
- (void)didReceiveMemoryWarning | |
{ | |
[super didReceiveMemoryWarning]; | |
// Dispose of any resources that can be recreated. | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment