numberOfRowsInSection causes grid bug


#1

Hi,

i’m using shinobiDataGrid and i’m having an issue when changing the number of rows for each section.

When i tap a cell, inside didTapCellAtCoordinate delegate method, i reload my two grids in order to change the number of rows of one of my sections.

- (void)shinobiDataGrid:(ShinobiDataGrid *)grid didTapCellAtCoordinate:(const SDataGridCoord *)gridCoordinate isDoubleTap:(BOOL)isDoubleTap
{
    
    [self.dataGridRecipesInMemory reload];
    [self.dataGridRecipeToModify reload];
 
}
 
- (NSUInteger)shinobiDataGrid:(ShinobiDataGrid *)grid numberOfRowsInSection:(NSInteger)sectionIndex
{
    return [[[groups objectAtIndex:sectionIndex] parameterRelationship] count]; //Core data relationship
 
 
}
- (void)shinobiDataGrid:(ShinobiDataGrid *)grid prepareCellForDisplay:(SDataGridCell *)cell
{
 
    PickerCell *myCell = (PickerCell*)cell;
    myCell.textField.text = @“Hello”;
    return;
 
}
 
Whenever i tap a cell that is close to the bottom of the grid, if after the tap i scroll up the grid, i see white sections, the column header disappear and all the cells of that grid are wrong placed.
 
The problem occurs only when tapping a cell that is (more or less) under the second half of the grid. If i tap on the first half i don't get the problem.
If i put a single number as return value of the numberOfRowsInSection method i don't get the problem (like 'return 5').
 
My grids contain 10 sections and they're synchronized when scrolling. 
 
Any help? I really need suggestions.
 
Thank you.
 
Cesare
 
 

}

#2

no one can help me please?


#3

Hi isis,

Thanks for getting in touch!

Is it possible for you to replicate your issue in one of our sample apps and send it to us at info@shinobicontrols.com?

This would really help us identify the source of your issue.

Kind regards,
Andrew Polkinghorn


#4

Greetings Programs!

isis wrote:
Whenever i tap a cell that is close to the bottom of the grid, if after the tap i scroll up the grid, i see white sections, the column header disappear and all the cells of that grid are wrong placed.

This reminds me of a situtation I ran into when the cell is reused and the content for the cell is not set in prepareCellForDisplay for the new column it’s in. I had to made sure all cells were set with data or at least cleared if there was no value in the datasource for the cell.

// Instead of doing this which set the cell even if the value was empty.
if ([cell.coordinate.column.title isEqualToString:@"surname"]) {
    textCell.textField.text = person.surname;
}

// I was doing this which didn't change the cell value and if the cell was reused,
// it contained the previous value making the grid cells look all jumbled up.
if ([cell.coordinate.column.title isEqualToString:@"surname"] && ![person.surname isEqualToString:@""]) {
    textCell.textField.text = person.surname;
}

In one of my apps, I am using a temporary array to hold the objects from Core Data and I don’t update them until the user is finished with the grid.

One thing that came to mind; I don’t know how you’ve got the grid set up but if you’re using Core Data and modifying the groups/entities and returning a relationship count from Core Data, is the NSManagedObjectContext updated/saved before the numberOfRowsInSection to return the new value?

Wg