react-native-easy-grid-view
Version:
Easy grid view for react-native
18 lines (15 loc) • 577 B
JavaScript
;
import {ListView} from "react-native";
class GridViewDataSource extends ListView.DataSource {
cloneWithCells(data, cellsInRow) {
var groupedData = [];
for (var i = 0; i < data.length; i++) {
groupedData[Math.floor(i / cellsInRow)] = groupedData[Math.floor(i / cellsInRow)] || [];
groupedData[Math.floor(i / cellsInRow)].push(data[i]);
}
var dataSource = super.cloneWithRows(groupedData);
dataSource.cellsInRow = cellsInRow;
return dataSource
}
}
export default GridViewDataSource;