{//Controls----------------------------------------------------------------------------------------------------------------------------------------------------------------------
	var cmdNew=$.ControlAdd('button_icon', [0,5,1000,22], body, {text: $.lng('new_f'), icon: 'new'});

	var columns=[{type: 'simple', key: 'formula', text: $.lng('formula'), width: '200'},
				{type: 'simple', key: 'value', text: $.lng('value'), width: '250'},
				{type: 'button', key: 'button', clickable: 'false', width: '120'},
				{type: 'hide'}
				];
	
	var grid=$.ControlAdd('grid', [0,33,1000,507], body, {sortable: false, editable: false, columns: columns});
	var win=FormulaWindow();
}
{//Events----------------------------------------------------------------------------------------------------------------------------------------------------------------------
	grid.onrowclick=function(row){ win.Load(row.key); }
	cmdNew.onclick=function(){
		var ajax=$.AjaxDB("SELECT Orden FROM LISTADOS_COLUMNAS{c} ORDER BY Orden DESC", Ajax.Wait);
		
		var order=ajax.json.row.length!=0?$.Convert.ToInt(ajax.json.row[0].Orden)+1:1;
		win.Load(order, true); 
	}
	
	grid.columnmodel.columns[2].oncellclick=function(cell){
		var key = cell.references.row.key;
		$.AjaxDBDelete('LISTADOS_FOR{c}', "Id='"+key+"'");
		$.AjaxDBDelete('LISTADOS_FOR_COL{c}', "IdFormula='"+key+"'");
		$.AjaxDBDelete('LISTADOS_COLUMNAS{c}', "Valor='"+key+"'");
		cell.references.row.Delete();
	}
}
Load_Report_List();