SDataGrid Cell Editing


#1

Is it possible to add next back navigation to the Keyboard that is displayed when a cell begins editing? I would like to allow our users to navigate to the next/previous row in the same column via these common Keyboard input accessories. I have been successful at adding the UIToolbar to the keyboard, but cannot determine how to force the next cell into Edit mode.


#2

Hi jklimm

To get this feature working you need to add your Input Accessory View to your editing cell’s textfield in the SDataGridDelegate method “shinobiDataGrid:willBeginEditingCellAtCoordinate:”. Like so:

- (void) shinobiDataGrid:(ShinobiDataGrid *)grid willBeginEditingCellAtCoordinate:(SDataGridCoord*) coordinate {
    SDataGridTextCell *cell = (SDataGridTextCell*)[grid visibleCellAtCoordinate:coordinate];
    [cell.textField setInputAccessoryView:inputAccView];
}

Then in the SDataGridDelegate method “shinobiDataGrid:didTapCellAtCoordinate:isDoubleTap:” save the SDataGridCoord parameter where you can access it by your Accessory View’s button event handlers. Like so:

-(void)shinobiDataGrid:(ShinobiDataGrid *)grid didTapCellAtCoordinate:(SDataGridCoord *)gridCoordinate isDoubleTap:(BOOL)isDoubleTap {
    if(isDoubleTap){
        self.gridCoord = [[[SDataGridCoord alloc] initWithCol:gridCoordinate.column row:gridCoordinate.row] autorelease];
    }
}

Then when you want to go up or down a row you need to disable the previous editing cell’s textfield and enable the cell we’re going to edit’s textfield. Like so:

-(void)previousRow {
    
    SDataGridTextCell *cell = (SDataGridTextCell*)[_shinobiDataGrid visibleCellAtCoordinate:self.gridCoord];
    // disable old cell
    cell.textField.enabled = NO;
    
    // Move up a row
    SDataGridRow *row = [[SDataGridRow alloc] initWithRowIndex:self.gridCoord.row.rowIndex - 1 withSectionindex:self.gridCoord.row.sectionIndex];
    
    self.gridCoord = [[[SDataGridCoord alloc] initWithCol:self.gridCoord.column row:row] autorelease];
    
    cell = (SDataGridTextCell*)[_shinobiDataGrid visibleCellAtCoordinate:self.gridCoord];
    // enable new cell
    cell.textField.enabled = YES;
    [cell.textField becomeFirstResponder];
}

Let me know how you get on.

Kind Regards,
Andrew Polkinghorn