js code wrapped to allow multiple grids

if you have multiple grids on the same page, only the last created is refreshed after a sorting operation