Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example implements handling of events related to table data source refresh, table area selection and table touch. After calling all the events their handling is disabled.
Executing the example requires to place the following code instead of the executeExample method of the ViewController class (see the Creating a Simple Data Grid section):
-(void) executeExample{ // Set whether table can be selected [contr setCanSelect: YES]; // Enable to handle events related with data source update [contr setSendEventBeforeAndAfterDataSourceUpdate: YES]; }; - (void)gridView:(NuGridView *)gridView wasTouchedInColumn:(NuGridColumn *)column{ // Display event call message NSLog(@"%@ %d", @"A column with number is touched", [column columnNumber]); // Select the column 2 [contr selectColumnByNumber: 2]; } - (void)gridView:(NuGridView *)gridView wasTouchedInRow:(NuGridRow *)row{ // Get data source ProxyDataSource *dataSource = [contr dataSource]; // Determine style NuGridCellStyle *cellStyle = [NuGridCellStyle deafultStyle]; // Remove images used by collapsed and expanded expander [cellStyle removeExpandedImage]; [cellStyle removeCollapsedImage]; [cellStyle setExpanderImageMargin:0]; // Set new font [cellStyle setFont:[UIFont fontWithName:@"Arial" size:15]]; // Change default style [dataSource gridView:(NuGridView *)[contr gridView] setDefaultStyle:cellStyle]; // Display event call message NSLog(@"%@ %d", @"A row with number is touched", [row rowNumber]); // Select column 2 [contr selectRowByNumber: 2]; // Disable to handle events related with data source update [contr setSendEventBeforeAndAfterDataSourceUpdate: NO]; } // Handle data source update end event - (void)gridViewActionAfterUpdate:(NuGridView *)gridView{ // Display event call message NSLog(@"%@", @"Data source change end event is initialized"); } // Handle data source update start event - (void)gridViewActionBeforeUpdate:(NuGridView *)gridView{ // Display event call message NSLog(@"%@", @"Data source change start event is initialized"); } // Handle event occurring before table row is selected - (void)gridView:(NuGridView *)gridView actionBeforeRowWithNumberSelected:(NSInteger)rowNumber{ NSLog(@"%@ %d", @"A row with number is started to be selected", rowNumber); } // Handle event occurring before table column is selected - (void)gridView:(NuGridView *)gridView actionBeforeColumnWithNumberSelected:(NSInteger)columnNumber{ NSLog(@"%@ %d", @"A column with number is started to be selected", columnNumber); } // Handle event occurring after table row is selected - (void)gridView:(NuGridView *)gridView actionAfterRowWithNumberSelected:(NSInteger)rowNumber{ NSLog(@"%@ %d", @"A row with number is ended to be selected", rowNumber); } // Handle event occurring after table column is selected - (void)gridView:(NuGridView *)gridView actionAfterColumnWithNumberSelected:(NSInteger)columnNumber{ NSLog(@"%@ %d", @"A column with number is ended to be selected", columnNumber); // Disable handling of events related to table selection [contr setSendEventBeforeAndAfterSelection:NO]; }
Press any table row header.
As a result, table data source style is changed, and the row 2 is selected:
The development environment console also displays information about call of handled events:
Data source change start event initialized
Data source change end event initialized
The row with the number 0 is touched
Selection of the row with the number 2 is started
Selection of the row with the number 2 is ended
Press any table column header.
As a result, the column with the number 2 is selected:
The development environment console also displays information about call of handled events:
The column with the number 0 is touched
Selection of the column with the number 2 is started
Selection of the column with the number 2 is ended
After executing the specified operations handling of the events related to table selection and data source refresh is disabled. On repeated pressing the table row and column headers, messages about call of corresponding events are not displayed.
See also: