Dynamic grid javascript generator