How to use SDataGridDelegate Edit callbacks with custom cell?


#1

I’m in the process of upgrading to ShinobiGrids 2.0. At first I was hopeful that there would be better support for custom cells, but that doesn’t seem to be the case. I have a custom view called a SelectView that is like a “combo box” where the user can type to filter a popover selection of values. They can then either select a value from the list or use the value they have typed as a new value to be added to the list. I am struggling to figure out how to drop this SelectView into a custom cell that extends SDataGridCell and make use of the Edit callbacks from SDataGridDelegate. My grid consists of some SDataGridTextCells and my custom cells, called SelectViewCell. In SelectViewCell, I’m just adding my SelectView as a subview. Everything renders fine, but none of the Edit callbacks are called when tapping. I’ve tried setting the edit tap mask to both “Single” and “Double” to no avail. The only callback I’m seeing is the “didTapCellAtCoordinate” callback when tapping any of my custom SelectViewCells.

How do I make use of the Edit callbacks for custom cells? I dont’ see a tutorial, example, or blog post about editing custom cells. When using the earlier version of ShinobiGrids, I had to make a hacky workaround, and I was hoping there would be a “real” way in this release. Advice?


#2

Hi Kungfuters,

There currently isn’t a way to tie in directly with the grids delegate for editing events when sub-classing. You should be able to achieve the behaviour your after by doing the following:

  1. Set your column to editable.

  2. Enable grid-wide editing like so:

    grid.doubleTapEventMask = SDataGridEventEdit;

  3. Implement the didTapCellAtCoordinate:isDoubleTap: SDataGridDelegate method you mentioned, and do something like below:

    • (void)shinobiDataGrid:(ShinobiDataGrid *)grid didTapCellAtCoordinate:(const SDataGridCoord *)gridCoordinate isDoubleTap:(BOOL)isDoubleTap
      {
      if (isDoubleTap) {
      [[grid cellAtCoord: gridCoordinate] doSomeEdityThing];
      }
      }

I understand that this isn’t exactly the answer you were hoping for, however, I have raised your suggestions with our development team. We really do appreciate feedback, especially on the usability of our current API, so if you have any other suggestions or issues, please either email them to info@shinobicontrols.com or make a post on our forum as you have done here.

I hope that the above helps and please feel free to ask any more questions.

Thanks,
Jan