How can I wrap text in a grid cell?


I am using the SDataGridTextCell and there is no way I can find to wrap the text in the cell. I have read about SDataGridMultiLineTextCell but it is crashing when I try and set textLabel…any thoughts? Code samples?



Swift : Auto Text in Shinobi Grid

Greetings Program!

How are you setting the textLabel of the SDataGridMultiLineTextCell?

I modified the HandlingEditing sample app to use the SDataGridMultiLineTextCell and entered 4 or 5 wrapped lines of text with no problems. What I did find was that if the row height isn’t big enough for the text label, the text is truncated with “…”.



Sounds great, so where can I find this sample code? I looked on github and cannot find the app.



It’s in the ShinobiGrids release archive: Samples -> DataGrid.



Im a trial user, does this mean I have to sign up for the trial again? (I tried downloading and its asking me to sign up).

I just need a code snippet if you have one. Also the charts library still wont compile for 64bit and the essentials library throws an error when combined with the grids framework. (duplicate symbol). Having a rough go at this so far…


Assuming you have an existing test project, instantiate the multiline column as such:

// Add a name column
    SDataGridColumn *nameColumn = [[SDataGridColumn alloc] initWithTitle:@"Forename" cellType:[SDataGridMultiLineTextCell class]];
    nameColumn.editable = YES;
    nameColumn.width = @250;
    [self.shinobiDataGrid addColumn:nameColumn];

I haven’t seen an auto resize row feature so you will have to make sure the height in the rows are enough for the wrapped text in the cell.

- (NSNumber *)shinobiDataGrid:(ShinobiDataGrid *)grid heightForRowAtIndex:(NSInteger)rowIndex inSection:(NSInteger)sectionIndex
    return @150;

In prepareCellForDisplay, set the cell text as such:

- (void)shinobiDataGrid:(ShinobiDataGrid *)grid prepareCellForDisplay:(SDataGridCell *)cell {
    // Locate the perspon that is rendered on this row
    PersonDataObject *person =[cell.coordinate.row.rowIndex];
    // Determine which column this cell belongs to
    if ([cell.coordinate.column.title isEqualToString:@"Forename"]) {
        // Cast the cell to our multiline text cell.
        SDataGridMultiLineTextCell *textCell = (SDataGridMultiLineTextCell*)cell;

        // Unlike the text field where you set the value as textCell.textField.text,
        // you set the text property of the textCell.
        textCell.text = person.forename;



Don’t know about the charts; you might want to start a new thread for the chart issue and see if the Shinobi Squad can address it.