ID form

Hi guys, I’m developing an application that I have so many windows with form attacheds.

These windows can be opened at the same time, but not the same.

I created a method that I call every time a open a window.

Here is the method:

this.iniciaformEditarCompleto = function (json,idjanela)
{
var id = gridPrincipal.getSelectedRowId();
if (id>0)
{

		formEditarCompleto = windowManager.window(idjanela).attachForm();
		formEditarCompleto.loadStruct(json.confformEditarCompleto, "json", function (){});			
		formEditarCompleto.attachEvent("onButtonClick", function (id)
		{
			
			if (id == "salvar")
			{
				formEditarCompleto.send("recebe_prototipo.aspl","post",function (loader, response){
				window.alert(response);
			});
			}
		});
	
		var label_vendas = gridPrincipal.cells(id,0).getValue();
		var label_livro = gridPrincipal.cells(id,1).getValue();
		var label_autor = gridPrincipal.cells(id,2).getValue();
		var label_preco = gridPrincipal.cells(id,3).getValue();
		var label_ativo = gridPrincipal.cells(id,4).getValue();
		var label_cadastro = gridPrincipal.cells(id,5).getValue();
		
		formEditarCompleto.setFormData({
			id : id,
			vendas : label_vendas,
			livro : label_livro,
			autor : label_autor,
			preco : label_preco,
			ativo : label_ativo,
		});
	}
	
};

Althoug, when I open more then one window, when I click save on the form, the data sent to server is the data of the last form attached on the last window opened, no matter what “save button” I click.

My question is: Can I apply differents IDs to the forms, and also, to attribute the save button to the respective form? How can I do it and save the correct data when I save the forms ?

Ps. excuse my bad english

Here is a print screen

These windows are opened with onRowDblClicked grid event

When I clicked on save button of the first form, the data sent was of the last opened form

I solved this issue with associative array

new method

this.iniciaformEditarCompleto = function (json,idjanela)
{
var id = gridPrincipal.getSelectedRowId();
if (id>0)
{
var formEditarCompleto = [];
formEditarCompleto[idjanela] = windowManager.window(idjanela).attachForm();
formEditarCompleto[idjanela].loadStruct(json.confformEditarCompleto, “json”, function (){});
formEditarCompleto[idjanela].attachEvent(“onButtonClick”, function (id)
{
if (id == “salvar”)
{
formEditarCompleto[idjanela].send(“recebe_prototipo.aspl”,“post”,function (loader, response){
window.alert(response);
});
}
});

		var label_vendas = gridPrincipal.cells(id,0).getValue();
		var label_livro = gridPrincipal.cells(id,1).getValue();
		var label_autor = gridPrincipal.cells(id,2).getValue();
		var label_preco = gridPrincipal.cells(id,3).getValue();
		var label_ativo = gridPrincipal.cells(id,4).getValue();
		var label_cadastro = gridPrincipal.cells(id,5).getValue();
		
		formEditarCompleto[idjanela].setFormData({
			id : id,
			vendas : label_vendas,
			livro : label_livro,
			autor : label_autor,
			preco : label_preco,
			ativo : label_ativo,
		});
		
		return formEditarCompleto[idjanela];
		//alert(formEditarCompleto[idjanela].getFormData().vendas);
	}
	
};