Change custom SDataGridCell style on row selection


#1

I created a simple custom SDataGridCell (called LabelGridCell) that contains a label (valueLabel) and I would like to change valueLabel textColor when I select the row to which it belongs, but SDataGridCell have no properties that i can use or observe. How can I do? :slight_frown:


#2

Greetings Program!

It seems like you’re not casting the cell correctly. See if this helps:

- (void)shinobiDataGrid:(ShinobiDataGrid *)grid didSelectRow:(SDataGridRow *)row
{
	if (_shinobiDataGrid.selectedCellCoordinates.count>0) {
		// Get the coordinates at the column index or you can loop through the coordinates
		// to find the correct cell with the required column title or cell type.
		SDataGridCoord *coord=[_shinobiDataGrid.selectedCellCoordinates objectAtIndex:3];
		LabelGridCell *cell=(LabelGridCell *)[_shinobiDataGrid visibleCellAtCoordinate:coord];
		
		NSLog(@"Selected cell %@ %@", cell, cell.coordinate.column.title);
		
		cell.valueLabel.textColor = [UIColor greenColor];
	}
}

Wg


#3

Hi Wg, 
Thanks! It works for me, I have to keep track of the previously  selected cells, and “deselect” them on new selection. Not so beautiful, but it works.

Max