Search feature in ShinobiGrids


#1

Does ShinobiGrids provide direct methods to show and perform search within the grids ?


#2

We don’t have searching, but we do offer sorting. Because the data is held by the datasource rather than the grid, any searching should be done in the provided datasource.

If you wanted to filter the results, then you would need to filter the data before it is passed to the grid through the datasource.


#3

Ok got it. So there is not direct method that will take the string from search input and reloads the grid with filtered rows.

Thanks


#4

If it helps, you might want to look into using an NSPredicate. This will allow you to quickly filter an array of values and return the subarray.

For example:

NSPredicate *namePredicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
            return [[evaluatedObject firstName] hasPrefix:@"Bob"];
        }];

NSArray *filteredData = [allData filteredArrayUsingPredicate:namePredicate];

[grid reloadData];

Then in the datasource methods, you would need to return the count and entries from the filteredData, instead of all of your data.


#5

This looks good. I will try it out.