/// <summary> /// Add bộ lọc cơ cấu tổ chức vào westpanel /// </summary> /// <param name="borderLayout"></param> /// <param name="currentUserID"></param> /// <param name="collapsed"></param> public void AddDepartmentList(Ext.Net.BorderLayout borderLayout, int currentUserID, bool collapsed) { Ext.Net.Panel panel = new Ext.Net.Panel() { Width = 220, Collapsed = collapsed, ID = "pnlCoCauToChuc", CtCls = "west-panel", Border = false, Layout = "BorderLayout", Title = "Cơ cấu tổ chức", }; Ext.Net.TreePanel treePanel = new Ext.Net.TreePanel() { RootVisible = false, AutoScroll = true, ID = "TreeCoCauToChuc", Border = false, Region = Ext.Net.Region.Center, Header = false }; Ext.Net.Toolbar tb = new Ext.Net.Toolbar(); Ext.Net.Button btnExpand = new Ext.Net.Button() { Icon = Ext.Net.Icon.ArrowOut, Text = "Mở rộng" }; btnExpand.Listeners.Click.Handler = "#{TreeCoCauToChuc}.expandAll();"; Ext.Net.Button btnCollapse = new Ext.Net.Button() { Text = "Thu nhỏ", Icon = Ext.Net.Icon.ArrowIn }; btnCollapse.Listeners.Click.Handler = "#{TreeCoCauToChuc}.collapseAll();"; tb.Items.Add(btnExpand); tb.Items.Add(btnCollapse); treePanel.TopBar.Add(tb); borderLayout.West.Split = true; borderLayout.West.Collapsible = true; borderLayout.West.Items.Add(panel); panel.Items.Add(treePanel); AddData(treePanel, currentUserID); }
public void LoadDefaultValues() { if (SetDefaultValues) { Border = EnableBorder; if (this.IdType == 0) this.IdType = IdType.Int; if (string.IsNullOrEmpty(Layout)) Layout = "fit"; #region TopBar if (!DisableTopBar) { Ext.Net.Toolbar toolBar = null; bool hasToolBar = this.TopBar != null && this.TopBar.Count > 0; if (hasToolBar) toolBar = (Ext.Net.Toolbar)this.TopBar.First(); else toolBar = new Ext.Net.Toolbar { ID = string.Format("toolbar{0}", ID) }; SubmitButton btnSave = null; if (!DisableSave && (HasAddPermission || HasUpdatePermission)) { btnSave = new SubmitButton { ID = string.Format("btnSave{0}", ID), Text = "Save", FormPanelID = this.FormPanelID, DisableSuccessHandler = this.DisableSuccessHandler, DisableFailureHandler = this.DisableFailureHandler }; } SubmitButton btnSaveAndNext = null; if (!DisableSaveAndNew && HasAddPermission) { btnSaveAndNext = new SubmitButton { ID = string.Format("btnSaveAndNext{0}", ID), Text = "Save and New", FormPanelID = this.FormPanelID, DisableSuccessHandler = this.DisableSuccessHandler, DisableFailureHandler = this.DisableFailureHandler, Icon = Ext.Net.Icon.Add, SetNew = true }; } Ext.Net.Button btnDelete = null; if (!DisableDelete && HasDeletePermission) { btnDelete = new Ext.Net.Button { ID = string.Format("btnDelete{0}", ID), Text = "Delete", Icon = Ext.Net.Icon.Cross }; btnDelete.DirectEvents.Click.Url = DeleteUrl; btnDelete.DirectEvents.Click.CleanRequest = true; btnDelete.DirectEvents.Click.Before = (BeforeDeleteHandler ?? string.Empty) + "#{" + ID + "}.getEl().mask('Deleting...');"; btnDelete.DirectEvents.Click.Failure = "#{" + ID + "}.getEl().unmask(); if(result.extraParams && result.extraParams.hasPermission && result.extraParams.hasPermission == '0') { Ax.ShowNotification('Warning', result.extraParams.msg, 'icon-exclamation'); } else { Ax.ShowNotification('Warning', result.extraParams.msg, 'icon-exclamation'); }" + (DeleteFailureHandler ?? string.Empty); btnDelete.DirectEvents.Click.Confirmation.ConfirmRequest = true; btnDelete.DirectEvents.Click.Confirmation.Title = "Alert"; btnDelete.DirectEvents.Click.Confirmation.Message = "Are you sure?"; btnDelete.DirectEvents.Click.ExtraParams.Add( new Ext.Net.Parameter { Name = "rows", Value = "[#{" + IDProperty + "}.value]", Mode = Ext.Net.ParameterMode.Raw }); } Ext.Net.Button btnClose = null; if (!DisableClose) { btnClose = new Ext.Net.Button { ID = string.Format("btnClose{0}", ID), Text = "Close", Icon = Ext.Net.Icon.Cancel }; } #region ToolbarOrder bool isOrdered = false; if (!string.IsNullOrEmpty(ToolbarOrder) && ToolbarOrder.IndexOf(',') != -1) { string[] buttons = ToolbarOrder.Split(','); int totalItemCount = toolBar.Items.Count; int controlItemCount = 4; if (buttons.Length == totalItemCount + controlItemCount) { isOrdered = true; Ext.Net.Component[] toolbarItems = new Ext.Net.Component[totalItemCount]; toolBar.Items.CopyTo(toolbarItems); toolBar.Items.Clear(); string controlIndex; int index = 0; int j = 0; for (int i = 0; i < buttons.Length; i++) { controlIndex = buttons[i].ToLower().Trim(); if (controlIndex == "0") { if (btnSave != null) { toolBar.Items.Insert(j, btnSave); j++; } } else if (controlIndex == "1") { if (btnSaveAndNext != null) { toolBar.Items.Insert(j, btnSaveAndNext); j++; } } else if (controlIndex == "2") { if (btnDelete != null) { toolBar.Items.Insert(j, btnDelete); j++; } } else if (controlIndex == "3") { if (btnClose != null) { toolBar.Items.Insert(j, btnClose); j++; } } else { if (Thesis.Common.Helpers.Ax.TryParse(controlIndex, ref index) && index >= controlItemCount) { toolBar.Items.Insert(j, toolbarItems[index - controlItemCount]); j++; } } } } } if(!isOrdered) { int index = 0; if (btnSave != null) { toolBar.Items.Insert(index, btnSave); index++; } if (btnSaveAndNext != null) { toolBar.Items.Insert(index, btnSaveAndNext); index++; } if (btnDelete != null) { toolBar.Items.Insert(index, btnDelete); index++; } if (btnClose != null) { toolBar.Items.Add(btnClose); } } #endregion if (!hasToolBar && toolBar.Items.Count > 0) TopBar.Add(toolBar); } #endregion if (!string.IsNullOrEmpty(IDProperty)) Listeners.Render.Handler += string.Format("var __isNew = {0}.value == '{1}'; var __btnDel = Ext.getCmp('btnDelete{2}'); if(__btnDel) __btnDel.setDisabled(__isNew);", IDProperty, (this.IdType == IdType.Guid ? Guid.Empty.ToString() : "0"), this.ID); if (!string.IsNullOrEmpty(SetDefaultUIValuesFn)) Listeners.Render.Handler += string.Format("{0}();", SetDefaultUIValuesFn); if (CheckDirty) { this.Items.Add(new Ext.Net.Hidden() { ID = string.Format("hdnFormObject_{0}", this.ID) }); Listeners.AfterRender.Handler += string.Format("#{{hdnFormObject_{0}}}.setValue(Ax.ClearDirtyForm(#{{{1}}}));", this.ID, this.FormPanelID); Listeners.AfterRender.Buffer = CheckDirtyBuffer > 0 ? CheckDirtyBuffer : 650; } } }
public void LoadDefaultValues() { if (SetDefaultValues) { StripeRows = !DisableStripeRows; Border = EnableBorder; TrackMouseOver = !DisableTrackMouseOver; #region Permissions bool hasAddPermission = true, hasDeletePermission = true; if (!string.IsNullOrEmpty(this.Module)) { List<ProcessTypes> permissions = ModuleAuthorizeService.GetModulePermissionsByModule(this.Module); if (permissions == null) { DisableVisible(); return; } else { if (permissions.IndexOf(ProcessTypes.View) == -1) { DisableVisible(); return; } hasAddPermission = permissions.IndexOf(ProcessTypes.Add) != -1; hasDeletePermission = permissions.IndexOf(ProcessTypes.Delete) != -1; } } #endregion #region TopBar Ext.Net.Button btnDelete = null; if (!DisableTopbar) { Ext.Net.Toolbar toolbar = null; bool hasToolBar = this.TopBar != null && this.TopBar.Count > 0; if (!hasToolBar) toolbar = new Ext.Net.Toolbar() { ID = string.Format("toolbar{0}", ID) }; else { toolbar = (Ext.Net.Toolbar)this.TopBar.First(); } #region BtnAdd Ext.Net.Button btnAdd = null; if (hasAddPermission && !DisableAdd && (DetailPage != null)) { btnAdd = new Ext.Net.Button { ID = string.Format("btnAdd{0}", this.ID), Text = "Add", Icon = Ext.Net.Icon.Add }; if (DetailPage != null) btnAdd.Listeners.Click.Handler = DetailPageScript(true); } #endregion #region BtnDelete if (hasDeletePermission && !DisableDelete && !string.IsNullOrEmpty(DeleteUrl)) { btnDelete = new Ext.Net.Button { ID = string.Format("btnDelete{0}", this.ID), Text = "Delete", Icon = Ext.Net.Icon.Delete, Disabled = true }; DeleteDirectEvent(btnDelete.DirectEvents.Click); } #endregion #region ToogleSearch Ext.Net.Button btnToogleSearch = null; if (this.EnableSearch && this.ToggleSearch) { btnToogleSearch = new Ext.Net.Button() { ID = string.Format("btnToogleSearch_{0}", this.ID), Icon = Ext.Net.Icon.TableLightning, Text="Filter", EnableToggle=true }; btnToogleSearch.Listeners.Click.Handler = string.Format("#{{panel_search_{0}}}.toggleCollapse();", this.ID); } #endregion #region BtnExport Ext.Net.Button btnExport = null; if (!DisableExport && (!DisableExcelExport || !DisableXmlExport || !DisableCsvExport)) { btnExport = new Ext.Net.Button { ID = string.Format("btnExport{0}", this.ID), Text = "Export", Icon = Ext.Net.Icon.DatabaseGo }; Ext.Net.Menu exportMenu = new Ext.Net.Menu(); if(!DisableExcelExport) exportMenu.Items.Add(new Ext.Net.MenuItem { Text = "Excel", Icon = Ext.Net.Icon.PageExcel }); if(!DisableXmlExport) exportMenu.Items.Add(new Ext.Net.MenuItem { Text = "XML", Icon = Ext.Net.Icon.PageCode }); if(!DisableCsvExport) exportMenu.Items.Add(new Ext.Net.MenuItem { Text = "CSV", Icon = Ext.Net.Icon.PageAttach }); exportMenu.DirectEvents.Click.IsUpload = true; exportMenu.DirectEvents.Click.CleanRequest = true; exportMenu.DirectEvents.Click.Url = ((Ext.Net.HttpProxy)this.Store[0].Proxy[0]).Url; exportMenu.DirectEvents.Click.FormID = this.FormID ?? "proxyForm"; exportMenu.DirectEvents.Click.ExtraParams.AddRange( new List<Ext.Net.Parameter> { new Ext.Net.Parameter{ Name="dir", Value = "#{" + this.ID + "}.store.sortInfo.direction", Mode= Ext.Net.ParameterMode.Raw }, new Ext.Net.Parameter{ Name="sort", Value = "#{" + this.ID + "}.store.sortInfo.field", Mode= Ext.Net.ParameterMode.Raw }, new Ext.Net.Parameter{ Name="ExportFormat", Value = "menuItem.iconCls", Mode= Ext.Net.ParameterMode.Raw }, new Ext.Net.Parameter{ Name="IsExport", Value = "true" } }); string[] exportParams = { "start", "limit", "dir", "sort", "exportformat", "isexport" }; foreach (Ext.Net.Parameter param in this.Store.Primary.BaseParams) { if(Array.IndexOf(exportParams, param.Name.ToLower().Trim()) == -1) exportMenu.DirectEvents.Click.ExtraParams.Add(param); } btnExport.Menu.Add(exportMenu); } #endregion #region ToolbarOrder bool isOrdered = false; if (!string.IsNullOrEmpty(ToolbarOrder) && ToolbarOrder.IndexOf(',') != -1) { string[] buttons = ToolbarOrder.Split(','); int totalItemCount = toolbar.Items.Count; int controlItemCount = 3; if (buttons.Length == totalItemCount + controlItemCount) { isOrdered = true; Ext.Net.Component[] toolbarItems = new Ext.Net.Component[totalItemCount]; toolbar.Items.CopyTo(toolbarItems); toolbar.Items.Clear(); string controlIndex; int index = 0; int j = 0; for (int i = 0; i < buttons.Length; i++) { controlIndex = buttons[i].ToLower().Trim(); if (controlIndex == "0") { if (btnAdd != null) { toolbar.Items.Insert(j, btnAdd); j++; } } else if (controlIndex == "1") { if (btnDelete != null) { toolbar.Items.Insert(j, btnDelete); j++; } } else if (controlIndex == "2") { if (btnToogleSearch != null) { toolbar.Items.Insert(j, btnToogleSearch); j++; } } else { if (Thesis.Common.Helpers.Ax.TryParse(controlIndex, ref index) && index >= controlItemCount) { toolbar.Items.Insert(j, toolbarItems[index - controlItemCount]); j++; } } } } } if (!isOrdered) { int index = 0; if (btnAdd != null) { toolbar.Items.Insert(index, btnAdd); index++; } if (btnDelete != null) { toolbar.Items.Insert(index, btnDelete); index++; } if (btnToogleSearch != null) { toolbar.Items.Insert(index, btnToogleSearch); } } #endregion toolbar.Items.Add(new Ext.Net.ToolbarFill()); if (btnExport != null) toolbar.Items.Add(btnExport); if (!hasToolBar) TopBar.Add(toolbar); } #endregion #region SelectionModel if (!DisableSelectionModel && SelectionModel.Count == 0) { Ext.Net.RowSelectionModel rowSelectionModel = new Ext.Net.RowSelectionModel(); rowSelectionModel.SingleSelect = SingleSelect; if (btnDelete != null) { rowSelectionModel.Listeners.RowSelect.Handler = "#{" + btnDelete.ID + "}.enable();"; rowSelectionModel.Listeners.RowDeselect.Handler = "if (!#{" + this.ID + "}.hasSelection()) {#{" + btnDelete.ID + "}.disable();}"; } SelectionModel.Add(rowSelectionModel); } #endregion #region BottomBar if (!DisableBottomBar && BottomBar.Count == 0) BottomBar.Add(new Ext.Net.PagingToolbar { PageSize = this.PageSize }); #endregion #region KeyMap if (!DisableKeyMap) { if (hasDeletePermission && !DisableDelete && !string.IsNullOrEmpty(DeleteUrl)) { if (btnDelete != null) { Ext.Net.KeyBinding deleteKey = new Ext.Net.KeyBinding(); deleteKey.StopEvent = true; deleteKey.Keys.Add(new Ext.Net.Key { Code = Ext.Net.KeyCode.DELETE }); deleteKey.Listeners.Event.Handler = "#{" + btnDelete.ID + "}.fireEvent('click', #{" + btnDelete.ID + "});"; KeyMap.Add(deleteKey); } else { Listeners.KeyDown.StopEvent = true; Listeners.KeyDown.Handler = "return e.browserEvent.keyCode == 46 && #{" + this.ID + "}.hasSelection();"; DeleteDirectEvent(DirectEvents.KeyDown); } } if (hasAddPermission && !DisableAdd && (DetailPage != null)) { Ext.Net.KeyBinding newRecord = new Ext.Net.KeyBinding(); newRecord.StopEvent = true; newRecord.Ctrl = true; newRecord.Keys.Add(new Ext.Net.Key { Code = Ext.Net.KeyCode.N }); newRecord.Listeners.Event.Handler = DetailPageScript(true); KeyMap.Add(newRecord); } if(DetailPage != null) { Ext.Net.KeyBinding detailKey = new Ext.Net.KeyBinding(); detailKey.StopEvent = true; detailKey.Keys.Add(new Ext.Net.Key { Code = Ext.Net.KeyCode.ENTER }); detailKey.Listeners.Event.Handler = DetailPageScript(false, "#{" + (this.ID ?? string.Empty) + "}", "Ax.GetSelectedRowIndex(#{" + (this.ID ?? string.Empty) + "})"); KeyMap.Add(detailKey); } } #endregion #region View if (AutoFillColumns && View.Count == 0) View.Add(new Ext.Net.GridView() { AutoFill=true }); #endregion if (DetailPage != null) Listeners.RowDblClick.Handler = DetailPageScript(false) + Listeners.RowDblClick.Handler; LoadMask.ShowMask = !DisableMask; } }
protected void AddSearchPanel(Ext.Net.Window parent, string caption, Guid identifier, TypeEnum type) { List<SearchExpression> searchList = this.SearchConditions; /* строка поиска */ Ext.Net.Toolbar searchBar = new Ext.Net.Toolbar(); searchBar.CtCls = "searchBar"; searchBar.Layout = "hbox"; /* text label */ Ext.Net.Label searchLabel = new Ext.Net.Label(caption); searchLabel.Margins = "4 2 2 2"; searchLabel.Flex = 1; searchBar.Add(searchLabel); /* combo box */ Ext.Net.ComboBox searchCombo = new Ext.Net.ComboBox(); searchCombo.CtCls = "condition"; searchCombo.Editable = false; searchCombo.Items.Add(new Ext.Net.ListItem("~")); if (type == TypeEnum.Integer || type == TypeEnum.Decimal) { searchCombo.Items.Add(new Ext.Net.ListItem(">")); searchCombo.Items.Add(new Ext.Net.ListItem("<")); searchCombo.Items.Add(new Ext.Net.ListItem("!~")); } searchCombo.SelectedIndex = 0; searchCombo.HiddenName = ""; searchCombo.Margins = "2 5 0 5"; searchCombo.Width = 80; searchCombo.SubmitValue = false; searchBar.Add(searchCombo); /* editor field */ Ext.Net.TextField searchField = new Ext.Net.TextField(); searchField.CtCls = "value"; searchField.Flex = 1; searchField.Margins = "2 2 0 0"; searchField.SubmitValue = false; if (type == TypeEnum.Integer) { searchField.Regex = @"^\d+$"; searchField.RegexText = "Введите целое число"; } if (type == TypeEnum.Decimal) { searchField.Regex = @"^\d+(,\d+)?$"; searchField.RegexText = "Введи вещественное число с запятой"; } if (type == TypeEnum.Boolean) { searchField.Regex = @"^0|1$"; searchField.RegexText = "Введи либо 0 (да) либо 1 (нет)"; } searchBar.Add(searchField); /* hidden value */ Ext.Net.Hidden searchIdent = new Ext.Net.Hidden(); searchIdent.CtCls = "identifier"; searchIdent.Value = identifier.ToString(); searchIdent.HideLabel = true; searchIdent.SubmitValue = false; searchBar.Add(searchIdent); parent.Items.Add(searchBar); /* Restore previous state */ try { SearchExpression searchExpr = searchList.First(p => p.FieldID == identifier); searchField.Value = searchExpr.FieldValue; searchCombo.Value = searchExpr.FieldCond.toString(); } catch {} }
private void BindGrid2Columns() { /* * Создание окна поиска */ Ext.Net.Toolbar bar = new Ext.Net.Toolbar(); bar.Layout = "hbox"; using (ContentDomain provider = Aspect.Model.Common.GetContentDomain(ClassifiacationTypeView)) { //List<SearchExpression> source = new List<SearchExpression>(); //List<IUserField> dictColumns = provider.GetUserFields(this.User.ID, RequestClassificationTreeID, FieldPlaceHolder.Grid); //List<UserProperty> columns = provider.GetUserPropertyColumns(this.User.ID, RequestClassificationTreeID, FieldPlaceHolder.Grid); // получаем пользовательские колонки для данного класса List<GridColumn> columns = provider.GetGridColumns(this.User.ID, RequestClassificationTreeID, FieldPlaceHolder.Grid); // извлекаем ширины колонок для данного класса List<ColumnWidth> columnWidths = provider.ColumnWidths.Where(p => p.ClassificationTreeID == RequestClassificationTreeID && p.UserID == this.User.ID).ToList(); List<GridColumn> gridColumns = provider.GetGridColumns(this.User.ID, RequestClassificationTreeID, FieldPlaceHolder.Grid); foreach (var column in gridColumns) { string fieldName = column.IsDictionary ? String.Format("{1} - {0}", column.Name, column.Group) : column.Name; /*IEnumerable<SearchExpression> list = this.SearchConditions.Where(s => s.FieldID == column.ID); source.Add(new SearchExpression() { FieldValue = list.Count() > 0 ? list.First().FieldValue : string.Empty, FieldName = fieldName, FieldID = column.ID, Order = column.Order });*/ AddSearchPanel(SearchWindow, fieldName, column.IsDictionary ? column.ID : column.SourceID, column.GridColumnType); } /* * Создание списка колонок в гриде продуктов */ foreach (GridColumn column in columns) { Ext.Net.ColumnBase newColumn; switch (column.GridColumnType) { case TypeEnum.Boolean: newColumn = new Ext.Net.CheckColumn(); break; default: newColumn = new Ext.Net.Column(); break; } newColumn.ColumnID = column.ID.ToString(); foreach (int width in columnWidths.Where(p => p.ColumnID == column.ID).Select(p => p.Width)) { newColumn.Width = width; } newColumn.Header = column.Alias; newColumn.Tooltip = column.IsDictionary ? String.Format("{0} :: {1}", column.Group, column.Name) : column.Name; newColumn.DataIndex = String.Format("{0}|{1}", column.OrderExpression, column.GridColumnType.ToString()); newColumn.Hideable = false; this.GridPanel1.ColumnModel.Columns.Add(newColumn); Store1.AddField(new Ext.Net.RecordField(newColumn.DataIndex)); } // adding another field Store1.AddField(new Ext.Net.RecordField("ID")); Store1.AddField(new Ext.Net.RecordField("CID")); } }