Hi Naveem,
What version of Mx Studio pro are you using?
In the new 10.6 update, they added conditionally visible columns for Datagrid 2.
Blog about 10.6: https://www.mendix.com/blog/release-10-6-ai-thats-a-lot/
Release notes: https://docs.mendix.com/releasenotes/studio-pro/10.6/
If possible i'd reccomend just using the 10.6 :)
Good luck!