js code wrapped to allow multiple grids

if you have multiple grids on the same page and you try to sort items of one of them, always the last one is refreshed, because the js varables are declared in the global scope, so they contains the value of the last grid created.