nlampi / SwiftGridView

Swift based data grid view.
MIT License
58 stars 15 forks source link

Dynamically change frozen columns ? #23

Closed lmljonathan closed 7 years ago

lmljonathan commented 7 years ago

Hi, first of all I'm loving this framework and its the most reliable I've found out there!

This is less of an issue but rather a question on how it would be done. So what I want to do is when someone taps on a header cell the number of frozen columns changes and the grid view reloads to account for that. Is there any way in which this can be done?

nlampi commented 7 years ago

Thanks for utilizing the component! I am still working on adding more tests and functionality, so it's good to hear. I believe this should be possible just by doing the steps you mentioned (update the frozen column count to match what was tapped and call reload). I think there shouldn't be much of an issue with speed/animation but I can run some trials to confirm.

nlampi commented 7 years ago

Sorry for the delay, but I have tested and think that you can utilize the didSelectHeaderAtIndexPath delegate method to update a local variable for the number of frozen columns and simply call reload data on the data grid.

func dataGridView(_ dataGridView: SwiftGridView, didSelectHeaderAtIndexPath indexPath: IndexPath) {
    self.frozenColumns = indexPath.sgColumn + 1
    dataGridView.reloadData()
}
lmljonathan commented 7 years ago

Thank you, I'll try implementing that to see if it works!

lmljonathan commented 7 years ago

I managed to accomplish this by creating another gridView :P