Deleting Rows from ShinobiDataGrid


#1

I see in the new version of ShinobiPlay that there is a sample grid where users can delete rows. The data object for SDataGridDataSourceHelperDelegateis not mutable (NSArray) so I am having trouble deleting rows on select. Any suggestions?


#2

Hi Asutka,

One way you can remove rows from your ShinobiDataGrid is by removing the data linked to the row from your SDataGridDataSource. Then you can reload your grid and it will render with those rows removed. You can reload your grid using the “reload” method and here is an example of what your code would look like: 

-(void) removeSelectedObjects {
    NSMutableArray *mutableDataArray = [_dataSourceHelper.data mutableCopy];
    for(int i = 0;i<_dataSourceHelper.selectedItems.count;i++){
        [mutableDataArray removeObject:_dataSourceHelper.selectedItems[i]];
    }
    _dataSourceHelper.data = [NSArray arrayWithArray:mutableDataArray];
    [_grid reload];
}

Where you would fire the “removeSelectedObjects” method when you want to remove the selected rows.

Kind Regards,
Andrew Polkinghorn


#3

Hi Andrew,

When calling [_grid reload], the grid sometimes sroll up & down awkwardly. Do you have any idea? I am using Version: 2.0.0, released on Apr 26 2013.

Thank you. 

Binh Nguyen