Your code for sorting works fine, thanks.
And for that column header thing, I am sending parameter to PHP like,
So this id will form a query like,
and forms grid.
SELECT id from table_name
When I pass parameter (this will be done with a button click event) first time and forms grid and works fine, but when I am not sending parameter again (second click) like,
It has the previously added column in the grid with no data like I shown in the picture.
I think what you mentioned there as JSON response is right, since there is no id in second click, JSON is empty and not showing data, but can we have like when there is not parameter sent, grid shouldn't form?