fix for grid rows and columns when grid dimensions or orientation is changed