Close a windows from a grid event

I have a window which contains a grid in my page and wich opens when I press a button.

I want to close the windows when the user clics a row in the grid.

I’ve tried to inicialize the dhxWins varible outside the function but I get an error.

Thanks for your help.


function buscar_Viajes(){


            var dhxWins = new dhtmlXWindows();         


            dhxWins.setViewport(90, 90, 435, 315);

   = “#909090 0px solid”;    


            var w1 = dhxWins.createWindow(“w1”,5, 5, 425, 305);        

            // hiding button max, min y contraer




             //No permite

            w1.denyResize(); // deny resizing

            w1.denyMove(); // deny moving             

            w1.setText(“Seleccionar Viaje”);        


            var grid = w1.attachGrid();



            //enable tooltips for last column


         //moverse entre las filas con el teclado


            //seleccionar fila con dobleclick






            //solo se puede seleccionar uno    





Make dhxWins global viriable.

When I put dhxWins = new dhtmlXWindows();   outside the function I get the following error when executing the BuscarViajes() function

‘dhxWins’ is not defined.

How can I declare It outside the function?

I wasn’t inicializing the variable after the tag. Now it works thanks!!!