public static void GridViewToolbarInit(object sender, EventArgs e) { ASPxGridView gridview = sender as ASPxGridView; var exportExcel = new GridViewToolbarItem(); exportExcel.Command = GridViewToolbarCommand.ExportToXlsx; var search = new GridViewToolbarItem(); search.Command = GridViewToolbarCommand.ShowSearchPanel; var refresh = new GridViewToolbarItem(); refresh.Command = GridViewToolbarCommand.Refresh; var clear = new GridViewToolbarItem(); clear.Command = GridViewToolbarCommand.ClearFilter; var newItem = new GridViewToolbarItem(); newItem.Command = GridViewToolbarCommand.New; var deleteItem = new GridViewToolbarItem(); deleteItem.Command = GridViewToolbarCommand.Delete; var editItem = new GridViewToolbarItem(); editItem.Command = GridViewToolbarCommand.Edit; var update = new GridViewToolbarItem(); update.Command = GridViewToolbarCommand.Update; update.Image.Url = "Images/ok.png"; update.Image.Height = GridViewUtils.ImageToolbarSize; update.Image.Width = GridViewUtils.ImageToolbarSize; var cancel = new GridViewToolbarItem(); cancel.Command = GridViewToolbarCommand.Cancel; cancel.Image.Url = "Images/nok.png"; cancel.Image.Height = GridViewUtils.ImageToolbarSize; cancel.Image.Width = GridViewUtils.ImageToolbarSize; var filter = new GridViewToolbarItem(); filter.Command = GridViewToolbarCommand.ShowFilterRow; filter.Image.Url = "Images/filter.png"; filter.Image.Height = GridViewUtils.ImageToolbarSize; filter.Image.Width = GridViewUtils.ImageToolbarSize; var toolbarGrid = new GridViewToolbar(); toolbarGrid.Name = GridViewUtils.ToolbarGrid; toolbarGrid.Position = GridToolbarPosition.Top; toolbarGrid.Items.Add(refresh); toolbarGrid.Items.Add(search); toolbarGrid.Items.Add(filter); toolbarGrid.Items.Add(clear); toolbarGrid.Items.Add(exportExcel); if (toolbarGrid.Items.Count > 0) { gridview.Toolbars.Add(toolbarGrid); } var toolbarItem = new GridViewToolbar(); toolbarItem.Name = GridViewUtils.ToolbarItem; toolbarItem.Position = GridToolbarPosition.Top; if (gridview.SettingsDataSecurity.AllowInsert) { toolbarItem.Items.Add(newItem); } if (gridview.SettingsDataSecurity.AllowEdit) { toolbarItem.Items.Add(editItem); } if (gridview.SettingsDataSecurity.AllowDelete) { toolbarItem.Items.Add(deleteItem); } if (toolbarItem.Items.Count > 0) { gridview.Toolbars.Add(toolbarItem); } if (gridview.SettingsEditing.Mode == GridViewEditingMode.Batch && (gridview.SettingsDataSecurity.AllowInsert || gridview.SettingsDataSecurity.AllowEdit || gridview.SettingsDataSecurity.AllowDelete)) { var toolbarBatch = new GridViewToolbar(); toolbarBatch.Name = GridViewUtils.ToolbarBatch; toolbarBatch.Position = GridToolbarPosition.Bottom; toolbarBatch.Items.Add(update); toolbarBatch.Items.Add(cancel); gridview.Settings.ShowStatusBar = GridViewStatusBarMode.Hidden; gridview.Toolbars.Add(toolbarBatch); } }
protected void gvAudit_Init(object sender, EventArgs e) { ASPxGridView gridview = sender as ASPxGridView; string activeLang = (Session["lang"] == null) ? Languages.Default : Utils.ConvertToTrimmedString(Session["lang"]); int imageSize = 40; int imageSizeToolbar = 40; var toolbarButtonColor = ColorTranslator.FromHtml("#D6D6D6"); var toolbarButtonHooverColor = ColorTranslator.FromHtml("#FFFFFF"); gridview.SettingsDataSecurity.AllowInsert = false; gridview.SettingsDataSecurity.AllowEdit = true; gridview.SettingsDataSecurity.AllowDelete = false; #region Image Buttons gridview.SettingsCommandButton.RenderMode = GridCommandButtonRenderMode.Image; gridview.SettingsCommandButton.NewButton.Image.AlternateText = "NEW"; gridview.SettingsCommandButton.NewButton.Image.ToolTip = gridview.SettingsCommandButton.NewButton.Image.AlternateText; gridview.SettingsCommandButton.NewButton.Image.Height = imageSize; gridview.SettingsCommandButton.NewButton.Image.Width = imageSize; gridview.SettingsCommandButton.NewButton.Image.Url = "Images/add.png"; gridview.SettingsCommandButton.EditButton.Image.AlternateText = "EDIT"; gridview.SettingsCommandButton.EditButton.Image.ToolTip = gridview.SettingsCommandButton.EditButton.Image.AlternateText; gridview.SettingsCommandButton.EditButton.Image.Height = imageSize; gridview.SettingsCommandButton.EditButton.Image.Width = imageSize; gridview.SettingsCommandButton.EditButton.Image.Url = "Images/edit.png"; gridview.SettingsCommandButton.DeleteButton.Image.AlternateText = "DELETE"; gridview.SettingsCommandButton.DeleteButton.Image.ToolTip = gridview.SettingsCommandButton.DeleteButton.Image.AlternateText; gridview.SettingsCommandButton.DeleteButton.Image.Height = imageSize; gridview.SettingsCommandButton.DeleteButton.Image.Width = imageSize; gridview.SettingsCommandButton.DeleteButton.Image.Url = "Images/trash.png"; gridview.SettingsCommandButton.UpdateButton.Image.AlternateText = "SAVE"; gridview.SettingsCommandButton.UpdateButton.Image.ToolTip = gridview.SettingsCommandButton.UpdateButton.Image.AlternateText; gridview.SettingsCommandButton.UpdateButton.Image.Height = imageSize; gridview.SettingsCommandButton.UpdateButton.Image.Width = imageSize; gridview.SettingsCommandButton.UpdateButton.Image.Url = "Images/ok.png"; gridview.SettingsCommandButton.CancelButton.Image.AlternateText = "CANCEL"; gridview.SettingsCommandButton.CancelButton.Image.ToolTip = gridview.SettingsCommandButton.CancelButton.Image.AlternateText; gridview.SettingsCommandButton.CancelButton.Image.Height = imageSize; gridview.SettingsCommandButton.CancelButton.Image.Width = imageSize; gridview.SettingsCommandButton.CancelButton.Image.Url = "Images/nok.png"; #endregion Image Buttons gridview.Settings.AutoFilterCondition = AutoFilterCondition.Contains; gridview.Settings.ShowFilterRowMenu = false; gridview.Settings.ShowHeaderFilterButton = false; gridview.Settings.ShowTitlePanel = true; gridview.Settings.VerticalScrollBarMode = ScrollBarMode.Visible; gridview.SettingsBehavior.ConfirmDelete = true; gridview.SettingsBehavior.AllowFocusedRow = true; gridview.SettingsBehavior.AllowSort = false; gridview.SettingsBehavior.AllowDragDrop = false; gridview.KeyboardSupport = true; gridview.SettingsLoadingPanel.Mode = GridViewLoadingPanelMode.ShowAsPopup; gridview.SettingsPager.AlwaysShowPager = false; gridview.SettingsPager.Mode = GridViewPagerMode.ShowAllRecords; gridview.SettingsPopup.EditForm.AllowResize = false; gridview.SettingsPopup.EditForm.HorizontalAlign = PopupHorizontalAlign.WindowCenter; gridview.SettingsPopup.EditForm.VerticalAlign = PopupVerticalAlign.WindowCenter; gridview.SettingsPopup.EditForm.VerticalOffset = -200; gridview.SettingsPopup.EditForm.Modal = true; gridview.SettingsPopup.EditForm.Width = new Unit("800px"); gridview.SettingsPopup.EditForm.ShowCloseButton = false; gridview.SettingsEditing.Mode = GridViewEditingMode.PopupEditForm; gridview.SettingsText.PopupEditFormCaption = "EDITION"; gridview.Styles.FocusedRow.BackColor = ColorTranslator.FromHtml("#0080FF"); gridview.Styles.Cell.HorizontalAlign = HorizontalAlign.Center; gridview.Styles.Header.HorizontalAlign = HorizontalAlign.Center; gridview.Styles.Header.Wrap = DevExpress.Utils.DefaultBoolean.True; gridview.StylesEditors.ReadOnly.BackColor = Color.Black; gridview.StylesEditors.ReadOnly.ForeColor = Color.White; gridview.Styles.TitlePanel.BackColor = ColorTranslator.FromHtml("#64645B"); gridview.Font.Size = new FontUnit("18px"); gridview.StylesToolbar.Style.ItemSpacing = new Unit("60px"); gridview.StylesToolbar.Style.Paddings.PaddingTop = new Unit("10px"); gridview.StylesToolbar.Style.Paddings.PaddingBottom = new Unit("10px"); gridview.Styles.LoadingPanel.BackColor = ColorTranslator.FromHtml("#FFFFB0"); gridview.Styles.LoadingPanel.ForeColor = ColorTranslator.FromHtml("#0080FF"); gridview.Styles.LoadingPanel.Font.Bold = true; gridview.Styles.LoadingPanel.Font.Size = new System.Web.UI.WebControls.FontUnit("12px"); #region TopToolbar var print = new GridViewToolbarItem(); print.Command = GridViewToolbarCommand.Custom; print.Name = ToolbarButtons.PrintAudit; print.Text = "Print"; print.Image.Url = "Images/printer.png"; var endAudit = new GridViewToolbarItem(); endAudit.Command = GridViewToolbarCommand.Custom; endAudit.Name = ToolbarButtons.EndAudit; endAudit.Text = "End"; endAudit.Image.Url = "Images/task-complete.png"; var deleteAudit = new GridViewToolbarItem(); deleteAudit.Command = GridViewToolbarCommand.Custom; deleteAudit.Name = ToolbarButtons.DeleteAudit; deleteAudit.Text = "Delete"; deleteAudit.Image.Url = "Images/trash.png"; var nextPage = new GridViewToolbarItem(); nextPage.Command = GridViewToolbarCommand.Custom; nextPage.Name = ToolbarButtons.NextPage; nextPage.Text = "Next"; nextPage.Image.Url = "Images/next.png"; var prevPage = new GridViewToolbarItem(); prevPage.Command = GridViewToolbarCommand.Custom; prevPage.Name = ToolbarButtons.PrevPage; prevPage.Text = "Prev"; prevPage.Image.Url = "Images/prev.png"; var polish = new GridViewToolbarItem(); polish.Command = GridViewToolbarCommand.Custom; polish.Name = ToolbarButtons.LangPol; polish.Text = "POL"; polish.Image.Url = "Images/poland.png"; var english = new GridViewToolbarItem(); english.Command = GridViewToolbarCommand.Custom; english.Name = ToolbarButtons.LangEng; english.Text = "ENG"; english.Image.Url = "Images/england.png"; var toolbarTop = new GridViewToolbar(); gridview.Toolbars.Add(toolbarTop); toolbarTop.Position = GridToolbarPosition.Top; toolbarTop.ItemAlign = GridToolbarItemAlign.Center; switch (activeLang) { case Languages.English: toolbarTop.Items.Add(polish); break; case Languages.Polish: toolbarTop.Items.Add(english); break; } toolbarTop.Items.Add(print); toolbarTop.Items.Add(endAudit); toolbarTop.Items.Add(deleteAudit); toolbarTop.Items.Add(prevPage); toolbarTop.Items.Add(nextPage); foreach (GridViewToolbarItem item in toolbarTop.Items) { item.Image.AlternateText = item.Text; item.Image.ToolTip = item.Text; item.Image.Height = imageSizeToolbar; item.Image.Width = imageSizeToolbar; item.ItemStyle.BackColor = toolbarButtonColor; item.ItemStyle.HoverStyle.BackColor = toolbarButtonHooverColor; } #endregion TopToolbar #region BotToolbar var editItem = new GridViewToolbarItem(); editItem.Command = GridViewToolbarCommand.Custom; editItem.Name = ToolbarButtons.Edit; editItem.Text = "Comment"; editItem.Image.Url = "Images/chat.png"; var answerOK = new GridViewToolbarItem(); answerOK.Command = GridViewToolbarCommand.Custom; answerOK.Name = ToolbarButtons.AnswerOK; answerOK.Text = "OK"; answerOK.Image.Url = "Images/ans_ok.png"; var answerNOK = new GridViewToolbarItem(); answerNOK.Command = GridViewToolbarCommand.Custom; answerNOK.Name = ToolbarButtons.AnswerNOK; answerNOK.Text = "NOK"; answerNOK.Image.Url = "Images/ans_nok.png"; var answerNC = new GridViewToolbarItem(); answerNC.Command = GridViewToolbarCommand.Custom; answerNC.Name = ToolbarButtons.AnswerNC; answerNC.Text = "NC"; answerNC.Image.Url = "Images/ans_nc.png"; var answerNA = new GridViewToolbarItem(); answerNA.Command = GridViewToolbarCommand.Custom; answerNA.Name = ToolbarButtons.AnswerNA; answerNA.Text = "NA"; answerNA.Image.Url = "Images/ans_na.png"; var camera = new GridViewToolbarItem(); camera.Command = GridViewToolbarCommand.Custom; camera.Name = ToolbarButtons.Camera; camera.Text = "Camera"; camera.Image.Url = "Images/camera.png"; var toolbarBot = new GridViewToolbar(); gridview.Toolbars.Add(toolbarBot); toolbarBot.Position = GridToolbarPosition.Bottom; toolbarBot.ItemAlign = GridToolbarItemAlign.Center; toolbarBot.Items.Add(answerOK); toolbarBot.Items.Add(answerNOK); toolbarBot.Items.Add(answerNC); toolbarBot.Items.Add(answerNA); toolbarBot.Items.Add(editItem); toolbarBot.Items.Add(camera); foreach (GridViewToolbarItem item in toolbarBot.Items) { item.Image.AlternateText = item.Text; item.Image.ToolTip = item.Text; item.Image.Height = imageSizeToolbar; item.Image.Width = imageSizeToolbar; item.ItemStyle.BackColor = toolbarButtonColor; item.ItemStyle.HoverStyle.BackColor = toolbarButtonHooverColor; } #endregion BotToolbar }