Call a prepareforSegue when click a row in ShinobiDataGrid


#1

How can i call another view controller (using StoryBoard prepareforSegue) ?


#2

Hi Ariel,

The delegate you’re looking for is:

  • (void) shinobiDataGrid:(ShinobiDataGrid *)grid didTapCellAtCoordinate:(const SDataGridCoord *) gridCoordinate isDoubleTap:(BOOL)isDoubleTap;

This is fired when a cell is tapped, from which you can find the row and do whatever you want.

Hope this helps,

Rob


#3

Since Search isn’t always perfect, here’s my example for using presentViewController from the thread http://www.shinobicontrols.com/forum/shinobicontrols/2013/11/simple-shinobidatagrid-formatting-of-cells/

- (void)shinobiDataGrid:(ShinobiDataGrid *)grid didTapCellAtCoordinate:(SDataGridCoord *)coordinate isDoubleTap:(BOOL)isDoubleTap
{
    // find the cell that was edited
    SDataGridTextCell *cell = (SDataGridTextCell*)[grid visibleCellAtCoordinate:coordinate];

    if ([cell.coordinate.column.title isEqualToString:@"Part/Service"] && isDoubleTap)
    {
	SDataGridRow *row = cell.coordinate.row;
	
	NSLog(@"\n----------------------------------\nRow: %@\nCell: %@\n----------------------------------\n", row, cell);
	
	// The view controller you want to present from the storyboard.
	UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
	PrintViewController *printViewController = [storyBoard instantiateViewControllerWithIdentifier:@"PrintViewController"];
	
	// Set any properties in the view controller that you need to.
	printViewController.serviceOrder = self.serviceOrder;
		
	[self presentViewController:printViewController animated:YES completion:nil];
    }
}

Wg


#4

thank you wizgod you are very helpful to all newbies like me,but im still encountering an error do you  a very simple sample code for this?  or do you know any sample link that i can check.


#5

I’ve updated the code with the missing part, it should be ok now. It was missing:

// find the cell that was edited
    SDataGridTextCell *cell = (SDataGridTextCell*)[grid visibleCellAtCoordinate:coordinate];

And the check for a double tap:

if ([cell.coordinate.column.title isEqualToString:@"Part/Service"] && isDoubleTap)

If you put this code in the HandleEditing sample app, it will push the same view controller:

- (void)shinobiDataGrid:(ShinobiDataGrid *)grid didTapCellAtCoordinate:(SDataGridCoord *)coordinate isDoubleTap:(BOOL)isDoubleTap
{
    // find the cell that was edited
	SDataGridTextCell *cell = (SDataGridTextCell*)[grid visibleCellAtCoordinate:coordinate];
	
    if ([cell.coordinate.column.title isEqualToString:@"Forename"] && isDoubleTap)
    {
		SDataGridRow *row = cell.coordinate.row;
		
		NSLog(@"\n----------------------------------\nRow: %@\nCell: %@\n----------------------------------\n", row, cell);
		
		// The view controller you want to present.
		ViewController *viewController = [[ViewController alloc] init];
		
		[self presentViewController:viewController animated:YES completion:nil];
    }
}

Wg