var ExportButton = Class.create(SimpleButton, { initialize: function($super, element, gridID, format) { this.element = $(element); $super(element); this.gridID = gridID; this.format = (typeof format == "undefined") ? "CSV" : String(format).toUpperCase(); }, getDataSourceURL: function(){ var dataSource = $(this.gridID).JSControl.DataSource(); if (!dataSource) return void alert("Data source does not exist (id=\"" + this.gridID + "\")"); return "/srv/" + dataSource.Feeder().ContName() + "/" + dataSource.Feeder().ObjName(); }, getURL: function(){ var dataSourceURL = this.getDataSourceURL(); if (!dataSourceURL) return ""; var date=new Date(); var params = { "Format": this.format, "Columns": $(this.gridID).JSControl.Columns(), "TimeZone": date.getTimezoneOffset() }; var title=$(this.gridID).JSControl.Title(); if (typeof(title)=="undefined") { var wnd=AControl.GetParentWindow(this.element); if (wnd) title=wnd.Title(); } this.filename=title+"."+this.format.toLowerCase(); if (typeof(this.filename) != "undefined") params["Filename"]=this.filename; return dataSourceURL + "/Export" + "?" + URLSerializeVS(params); }, OnClick: function(event){ GFileDownloader.Download(this.getURL()); } });