protected void Application_Start(object sender, EventArgs e) { if (!Ext.Net.ResourceManager.HasFactory("mybutton")) { Ext.Net.ResourceManager.AddFactory(delegate { var b = new Ext.Net.Button { Text = "Factory button", Handler = "Ext.Msg.alert('Factory button', 'The button is clicked');", Plugins = { new Badge { Text = "20" } }, Factory = new FactoryConfig { Alias = "mybutton", Instance = "My.Button" } }; return(b); }, "mybutton", "My.Button"); } if (!Ext.Net.ResourceManager.HasFactory("mywindow")) { Ext.Net.ResourceManager.AddFactory("~/Examples/Miscellaneous/Factory/Basic/MyWindow.ascx", "mywindow", "My.Window"); } }
protected void Application_Start(object sender, EventArgs e) { if (!Ext.Net.ResourceManager.HasFactory("mybutton")) { Ext.Net.ResourceManager.AddFactory(delegate { var b = new Ext.Net.Button { Text = "Factory button", Handler = "Ext.Msg.alert('Factory button', 'The button is clicked');", Plugins = { new Badge { Text = "20" } }, Factory = new FactoryConfig { Alias = "mybutton", Instance = "My.Button" } }; return b; }, "mybutton", "My.Button"); } if (!Ext.Net.ResourceManager.HasFactory("mywindow")) { Ext.Net.ResourceManager.AddFactory("~/Examples/Miscellaneous/Factory/Basic/MyWindow.ascx", "mywindow", "My.Window"); } }
/// <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); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); if (!Ext.Net.ResourceManager.HasFactory("mybutton")) { Ext.Net.ResourceManager.AddFactory(delegate { var b = new Ext.Net.Button { Text = "Factory button", Handler = "Ext.Msg.alert('Factory button', 'The button is clicked');", Plugins = { new Badge { Text = "20" } }, Factory = new FactoryConfig { Alias = "mybutton", Instance = "My.Button" } }; return b; }, "mybutton", "My.Button"); } if (!Ext.Net.ResourceManager.HasFactory("mywindow1")) { Ext.Net.ResourceManager.AddFactoryView("~/Areas/Miscellaneous_Factory/Views/Basic/MyWindow1.ascx", "mywindow1", "My.Window1"); } if (!Ext.Net.ResourceManager.HasFactory("mywindow2")) { Ext.Net.ResourceManager.AddFactoryView("~/Areas/Miscellaneous_Factory/Views/Basic/MyWindow2.cshtml", "mywindow2", "My.Window2"); } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); if (!Ext.Net.ResourceManager.HasFactory("mybutton")) { Ext.Net.ResourceManager.AddFactory(delegate { var b = new Ext.Net.Button { Text = "Factory button", Handler = "Ext.Msg.alert('Factory button', 'The button is clicked');", Plugins = { new Badge { Text = "20" } }, Factory = new FactoryConfig { Alias = "mybutton", Instance = "My.Button" } }; return(b); }, "mybutton", "My.Button"); } if (!Ext.Net.ResourceManager.HasFactory("mywindow1")) { Ext.Net.ResourceManager.AddFactoryView("~/Areas/Miscellaneous_Factory/Views/Basic/MyWindow1.ascx", "mywindow1", "My.Window1"); } if (!Ext.Net.ResourceManager.HasFactory("mywindow2")) { Ext.Net.ResourceManager.AddFactoryView("~/Areas/Miscellaneous_Factory/Views/Basic/MyWindow2.cshtml", "mywindow2", "My.Window2"); } }
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 static Ext.Net.BorderLayout SearchPanel(GridPanel grid, bool isParentPanel) { string gridID = grid.ID; #region Main Panel Ext.Net.Panel mainPanel = new Ext.Net.Panel() { ID = string.Format("panel_search_{0}", gridID), Border = false, Collapsed = true, Collapsible = true, CollapseMode = grid.SearchCollapseMode, Height = 140, Title = "Filter" }; if (grid.ToggleSearch) { mainPanel.Listeners.Collapse.Handler = string.Format("var btnFilterToggle = #{{btnToogleSearch_{0}}}; if(btnFilterToggle && btnFilterToggle.pressed) btnFilterToggle.toggle();", gridID); mainPanel.Listeners.Expand.Handler = string.Format("var btnFilterToggle = #{{btnToogleSearch_{0}}}; if(btnFilterToggle && !btnFilterToggle.pressed) btnFilterToggle.toggle();", gridID); } #region Container Search Ext.Net.Panel searchPanel = new Ext.Net.Panel() { ID = string.Format("container_search_{0}", gridID), Border = false, Layout = "hbox", StyleSpec = "padding: 10px;" }; #region SelectBox Columns Ext.Net.SelectBox selectboxColumns = new Ext.Net.SelectBox() { ID = string.Format("SearchBox_{0}", gridID), EmptyText = "Select a column", AllowBlank = false }; var columns = grid.ColumnModel.Columns; Column axiomColumn = null; ColumnBaseType columnType = ColumnBaseType.String; foreach (var column in columns) { if (column is Column) { axiomColumn = column as Column; if (axiomColumn.DataType == 0) axiomColumn.DataType = ColumnBaseType.String; selectboxColumns.Items.Add(new Ext.Net.ListItem { Text = axiomColumn.Header, Value = string.Format("{0}_{1}", axiomColumn.DataIndex, axiomColumn.DataType.ToString().ToLower(new System.Globalization.CultureInfo("en-US"))) }); } else { Ext.Net.RecordFieldType fieldType = GetFieldType(column); switch (fieldType) { case Ext.Net.RecordFieldType.Auto: columnType = ColumnBaseType.String; break; case Ext.Net.RecordFieldType.Boolean: columnType = ColumnBaseType.Bool; break; case Ext.Net.RecordFieldType.Date: columnType = ColumnBaseType.Date; break; case Ext.Net.RecordFieldType.Float: columnType = ColumnBaseType.Float; break; case Ext.Net.RecordFieldType.Int: columnType = ColumnBaseType.Int; break; case Ext.Net.RecordFieldType.String: columnType = ColumnBaseType.String; break; default: columnType = ColumnBaseType.String; break; } selectboxColumns.Items.Add(new Ext.Net.ListItem { Text = column.Header, Value = string.Format("{0}_{1}", column.DataIndex, columnType.ToString().ToLower(new System.Globalization.CultureInfo("en-US"))) }); } } selectboxColumns.Listeners.Select.Handler = string.Format(@"if(#{{compositeField_whereCondition_{0}}}.hidden) #{{compositeField_whereCondition_{0}}}.show(); #{{container_search_{0}}}.items.each(function (b) {{ if (b.xtype == 'container') b.hide(); }}); var type = this.value.split('_')[1]; if(type == 'int' || type == 'float') {{ var isFloat = type == 'float'; Ax.DisableDecimals(#{{numberfield_start_numeric_{0}}}, isFloat); Ax.DisableDecimals(#{{numberfield_end_numeric_{0}}}, isFloat); type = 'numeric'; }} Ext.getCmp('container_' + type + '_{0}').show();", gridID); if (isParentPanel) selectboxColumns.Listeners.Select.Handler += string.Format("if(type == 'numeric') {{ #{{numberfield_start_numeric_{0}}}.reset(); }}", gridID); selectboxColumns.SelectedIndex = grid.SelectedFilterColumnIndex; searchPanel.Items.Add(selectboxColumns); #endregion #region First Column Type string firstColumnType = selectboxColumns.Items.Count > 0 ? selectboxColumns.Items[selectboxColumns.SelectedIndex].Value.Split('_')[1] : string.Empty; bool hasFirstColumn = firstColumnType != string.Empty; #endregion #region Container String Ext.Net.Container container_string = new Ext.Net.Container() { ID = string.Format("container_string_{0}", gridID), StyleSpec = "left:165px;" }; if (!(hasFirstColumn && firstColumnType == "string")) { container_string.Listeners.AfterRender.Handler = "item.el.setStyle('margin-left', Ext.isIE ? '14px' : '6px'); item.hide();"; } else { container_string.StyleSpec += "margin-left:6px;"; container_string.Listeners.AfterRender.Handler = "item.show();"; } container_string.Listeners.BeforeShow.Handler = string.Format("#{{selectbox_string_filterCondition_{0}}}.selectFirst();", gridID); container_string.Listeners.BeforeShow.Delay = 100; container_string.Listeners.Hide.Handler = string.Format("#{{selectbox_string_filterCondition_{0}}}.reset(); #{{textField_string_{0}}}.reset();", gridID); CompositeField compositeField_string = new CompositeField() { ID = string.Format("compositeField_string_{0}", gridID), Width = 500 }; if (hasFirstColumn && firstColumnType == "string") { compositeField_string.Listeners.AfterRender.Handler = "item.el.first().setStyle('height', '23px');"; compositeField_string.Listeners.AfterRender.Delay = 150; } Ext.Net.SelectBox selectBox_string = new Ext.Net.SelectBox() { ID = string.Format("selectbox_string_filterCondition_{0}", gridID), AllowBlank = false, Width = 107 }; selectBox_string.Items.AddRange(new List<Ext.Net.ListItem>() { new Ext.Net.ListItem() { Text = "Starts With", Value="StartsWith" }, new Ext.Net.ListItem() { Text = "Ends With", Value="EndsWith" }, new Ext.Net.ListItem() { Text = "Contains", Value="Contains" }, new Ext.Net.ListItem() { Text = "Equals", Value="Equals" }, new Ext.Net.ListItem() { Text = "Not Equal", Value="NotEqual" } }); selectBox_string.SelectedIndex = 0; Ext.Net.TextField textfield_string = new Ext.Net.TextField() { ID = string.Format("textField_string_{0}", gridID), StyleSpec = "margin-left:8px;", AllowBlank = false, MinLength = 1, EmptyText = "Type a filter" }; compositeField_string.Items.Add(selectBox_string); compositeField_string.Items.Add(textfield_string); container_string.Items.Add(compositeField_string); searchPanel.Items.Add(container_string); #endregion #region Container DateTime Ext.Net.Container container_date = new Ext.Net.Container() { ID = string.Format("container_date_{0}", gridID), StyleSpec = "left:165px;" }; if (!(hasFirstColumn && firstColumnType == "date")) { container_date.Listeners.AfterRender.Handler = "item.el.setStyle('margin-left', Ext.isIE ? '14px' : '6px'); item.hide();"; } else { container_date.StyleSpec += "margin-left:6px;"; container_date.Listeners.AfterRender.Handler = "item.show();"; } container_date.Listeners.BeforeShow.Handler = string.Format("#{{selectbox_date_filterCondition_{0}}}.selectFirst();", gridID); container_date.Listeners.BeforeShow.Delay = 100; container_date.Listeners.Hide.Handler = string.Format(@"#{{selectbox_date_filterCondition_{0}}}.reset(); #{{datefield_start_filterCondition_{0}}}.reset(); #{{datefield_start_filterCondition_{0}}}.setMaxValue(null); #{{datefield_end_filterCondition_{0}}}.reset(); #{{datefield_end_filterCondition_{0}}}.allowBlank = true; #{{panel_between_date_{0}}}.hide();", gridID); CompositeField compositeField_date = new CompositeField() { ID = string.Format("compositeField_date_{0}", gridID), Width = 500 }; if (hasFirstColumn && firstColumnType == "date") { compositeField_date.Listeners.AfterRender.Handler = "item.el.first().setStyle('height', '23px');"; compositeField_date.Listeners.AfterRender.Delay = 200; } Ext.Net.SelectBox selectBox_date = new Ext.Net.SelectBox() { ID = string.Format("selectbox_date_filterCondition_{0}", gridID), AllowBlank = false, Width=107 }; selectBox_date.Items.AddRange(new List<Ext.Net.ListItem>() { new Ext.Net.ListItem() { Text = "Equals", Value = "Equals" }, new Ext.Net.ListItem() { Text = "Not Equal", Value="NotEqual" }, new Ext.Net.ListItem() { Text = "Greater Than", Value = "Greater" }, new Ext.Net.ListItem() { Text = "Less Than", Value = "Less" }, new Ext.Net.ListItem() { Text = "Between", Value = "Between" } }); selectBox_date.SelectedIndex = 0; selectBox_date.Listeners.Select.Handler = string.Format(@"var selectedValue = this.getValue(); var isBetween = selectedValue == 'Between'; panel_between_date_{0}[isBetween ? 'show' : 'hide'](); #{{datefield_end_filterCondition_{0}}}.allowBlank = !isBetween; if(isBetween) #{{datefield_end_filterCondition_{0}}}.reset(); else #{{datefield_start_filterCondition_{0}}}.setMaxValue(null);", gridID); DateField dateField_start = new DateField() { ID = string.Format("datefield_start_filterCondition_{0}", gridID), EndDateField = string.Format("datefield_end_filterCondition_{0}", gridID), AllowBlank = false, EmptyText = "Select a start date", Width = 128, StyleSpec = "margin-left:8px;" }; Ext.Net.Panel panel_between_date = new Ext.Net.Panel() { ID = string.Format("panel_between_date_{0}", gridID), Border = false, Hidden = true, StyleSpec = "padding-left:13px;" }; CompositeField compositeField_between_date = new CompositeField() { ID = string.Format("compositeField_between_date_{0}", gridID), Width = 200, }; Ext.Net.DisplayField displayField_date_and = new Ext.Net.DisplayField() { ID = string.Format("displayfield_date_and_{0}", gridID), Text = "and", StyleSpec = "margin-top:4px;" }; DateField dateField_end = new DateField() { ID = string.Format("datefield_end_filterCondition_{0}", gridID), StartDateField = string.Format("datefield_start_filterCondition_{0}", gridID), EmptyText = "Select a end date", Width = 128, StyleSpec = "margin-left:6px;" }; compositeField_between_date.Items.Add(displayField_date_and); compositeField_between_date.Items.Add(dateField_end); panel_between_date.Items.Add(compositeField_between_date); compositeField_date.Items.Add(selectBox_date); compositeField_date.Items.Add(dateField_start); compositeField_date.Items.Add(panel_between_date); container_date.Items.Add(compositeField_date); searchPanel.Items.Add(container_date); #endregion #region Container Numeric Ext.Net.Container container_numeric = new Ext.Net.Container() { ID = string.Format("container_numeric_{0}", gridID), StyleSpec = "left:165px;" }; if (!(hasFirstColumn && (firstColumnType == "float" || firstColumnType == "int"))) { container_numeric.Listeners.AfterRender.Handler = "item.el.setStyle('margin-left', Ext.isIE ? '14px' : '6px'); item.hide();"; } else { container_numeric.StyleSpec += "margin-left:6px;"; container_numeric.Listeners.AfterRender.Handler = "item.show();"; } container_numeric.Listeners.BeforeShow.Handler = string.Format("#{{selectbox_numeric_filterCondition_{0}}}.selectFirst();", gridID); container_numeric.Listeners.BeforeShow.Delay = 100; container_numeric.Listeners.Hide.Handler = string.Format(@"#{{selectbox_numeric_filterCondition_{0}}}.reset(); #{{numberfield_start_numeric_{0}}}.reset(); #{{numberfield_start_numeric_{0}}}.setMaxValue(null); #{{numberfield_end_numeric_{0}}}.reset(); #{{numberfield_end_numeric_{0}}}.allowBlank = true; #{{panel_between_numeric_{0}}}.hide();", gridID); CompositeField compositeField_numeric = new CompositeField() { ID = string.Format("compositeField_numeric_{0}", gridID), Width = 500 }; if (hasFirstColumn && (firstColumnType == "float" || firstColumnType == "int")) { compositeField_numeric.Listeners.AfterRender.Handler = "item.el.first().setStyle('height', '23px');"; compositeField_numeric.Listeners.AfterRender.Delay = 150; } Ext.Net.SelectBox selectBox_numeric = new Ext.Net.SelectBox() { ID = string.Format("selectbox_numeric_filterCondition_{0}", gridID), AllowBlank = false, Width = 107 }; selectBox_numeric.Items.AddRange(new List<Ext.Net.ListItem>() { new Ext.Net.ListItem() { Text = "Equals", Value = "Equals" }, new Ext.Net.ListItem() { Text = "Not Equal", Value="NotEqual" }, new Ext.Net.ListItem() { Text = "Greater Than", Value = "Greater" }, new Ext.Net.ListItem() { Text = "Less Than", Value = "Less" }, new Ext.Net.ListItem() { Text = "Between", Value = "Between" } }); selectBox_numeric.SelectedIndex = 0; selectBox_numeric.Listeners.Select.Handler = string.Format(@"var selectedValue = this.getValue(); var isBetween = selectedValue == 'Between'; panel_between_numeric_{0}[isBetween ? 'show' : 'hide'](); #{{numberfield_end_numeric_{0}}}.allowBlank = !isBetween; if(isBetween) #{{numberfield_end_numeric_{0}}}.reset(); else {{ #{{numberfield_start_numeric_{0}}}.setMaxValue(null); if(#{{numberfield_start_numeric_{0}}}.getValue() != '') #{{numberfield_start_numeric_{0}}}.validate(); }}", gridID); NumberField numberField_start = new NumberField() { ID = string.Format("numberfield_start_numeric_{0}", gridID), EndNumberField = string.Format("numberfield_end_numeric_{0}", gridID), AllowBlank = false, EmptyText = "Type a filter", StyleSpec = "margin-left:8px;text-align:right;" }; Ext.Net.Panel panel_between_numeric = new Ext.Net.Panel() { ID = string.Format("panel_between_numeric_{0}", gridID), Border = false, Hidden = true, StyleSpec = "padding-left: 13px;" }; CompositeField compositeField_between_numeric = new CompositeField() { ID = string.Format("compositeField_between_numeric_{0}", gridID), Width = 200 }; Ext.Net.DisplayField displayField_numeric_and = new Ext.Net.DisplayField() { ID = string.Format("displayfield_numeric_and_{0}", gridID), Text = "and", StyleSpec = "margin-top:4px;" }; NumberField numberField_end = new NumberField() { ID = string.Format("numberfield_end_numeric_{0}", gridID), StartNumberField = string.Format("numberfield_start_numeric_{0}", gridID), EmptyText = "Type a filter", StyleSpec = "margin-left:6px;text-align:right;" }; compositeField_between_numeric.Items.Add(displayField_numeric_and); compositeField_between_numeric.Items.Add(numberField_end); panel_between_numeric.Items.Add(compositeField_between_numeric); compositeField_numeric.Items.Add(selectBox_numeric); compositeField_numeric.Items.Add(numberField_start); compositeField_numeric.Items.Add(panel_between_numeric); container_numeric.Items.Add(compositeField_numeric); searchPanel.Items.Add(container_numeric); #endregion #region Container Bool Ext.Net.Container container_bool = new Ext.Net.Container() { ID = string.Format("container_bool_{0}", gridID), StyleSpec = "left:165px;" }; if (!(hasFirstColumn && firstColumnType == "bool")) { container_bool.Listeners.AfterRender.Handler = "item.el.setStyle('margin-left', Ext.isIE ? '14px' : '6px'); item.hide();"; } else { container_bool.StyleSpec += "margin-left:6px;"; container_bool.Listeners.AfterRender.Handler = "item.show();"; } container_bool.Listeners.BeforeShow.Handler = string.Format("#{{selectbox_bool_filterCondition_{0}}}.selectFirst();", gridID); container_bool.Listeners.BeforeShow.Delay = 100; container_bool.Listeners.Hide.Handler = string.Format("#{{selectbox_bool_filterCondition_{0}}}.reset();", gridID); CompositeField compositeField_bool = new CompositeField() { ID = string.Format("compositeField_bool_{0}", gridID), Width = 500 }; if (hasFirstColumn && firstColumnType == "bool") { compositeField_bool.Listeners.AfterRender.Handler = "item.el.first().setStyle('height', '23px');"; compositeField_bool.Listeners.AfterRender.Delay = 150; } Ext.Net.SelectBox selectBox_bool = new Ext.Net.SelectBox() { ID = string.Format("selectbox_bool_filterCondition_{0}", gridID), AllowBlank = false, Width=107 }; selectBox_bool.Items.AddRange(new List<Ext.Net.ListItem>() { new Ext.Net.ListItem { Text = "True", Value = "true" }, new Ext.Net.ListItem { Text = "False", Value = "false" } }); selectBox_bool.SelectedIndex = 0; compositeField_bool.Items.Add(selectBox_bool); container_bool.Items.Add(compositeField_bool); searchPanel.Items.Add(container_bool); #endregion #endregion #region CompositeField Where Condition CompositeField compositeField_whereCondition = new CompositeField() { ID = string.Format("compositeField_whereCondition_{0}", gridID), Hidden = !hasFirstColumn, Width = 500, StyleSpec = "padding-left:10px;" }; Ext.Net.SelectBox selectBox_whereCondition = new Ext.Net.SelectBox() { ID = string.Format("selectbox_whereCondition_{0}", gridID), Width = 100, AllowBlank = false }; selectBox_whereCondition.Items.AddRange(new List<Ext.Net.ListItem>() { new Ext.Net.ListItem() { Text = "And", Value = "And" }, new Ext.Net.ListItem() { Text = "Or", Value = "Or" } }); selectBox_whereCondition.SelectedIndex = 0; Ext.Net.Button button_search = new Ext.Net.Button() { ID = string.Format("button_search_{0}", gridID), Text = "Add Filter", StyleSpec = "left:100px; margin-left:10px;" }; button_search.Listeners.Click.Handler = string.Format(@"var type = #{{SearchBox_{0}}}.value.split('_')[1]; if(type == 'int' || type == 'float') {{ type = 'numeric'; }} var cf = Ext.getCmp('compositeField_' + type + '_{0}'); if(!Ax.IsValidComponent(cf)) return; var cp = #{{panel_SearchCondition_{0}}}; var filterItemLength = cp.items.length; var filterId = Ax.UUID(); var selectWhere = #{{selectbox_whereCondition_{0}}}; var filterText = filterItemLength > 0 ? selectWhere.getRawValue() + ' ' : ''; filterText += #{{SearchBox_{0}}}.getRawValue(); filterText += ' '; var filterItem = ''; if(type == 'string') {{ filterText += #{{selectbox_string_filterCondition_{0}}}.getRawValue(); filterText += ' '; filterText += Ax.FormatFilterText(#{{textField_string_{0}}}.getValue()); filterItem += Ax.FilterItem(filterId, #{{SearchBox_{0}}}.value.split('_')[0], selectWhere.getValue(), #{{selectbox_string_filterCondition_{0}}}.getValue(), #{{textField_string_{0}}}.getValue(), ''); }} else if(type == 'date') {{ filterText += #{{selectbox_date_filterCondition_{0}}}.getRawValue(); filterText += ' '; filterText += #{{datefield_start_filterCondition_{0}}}.getRawValue(); var isBetween = #{{selectbox_date_filterCondition_{0}}}.getValue() == 'Between'; if(isBetween) {{ filterText += ' and '; filterText += #{{datefield_end_filterCondition_{0}}}.getRawValue(); }} filterItem += Ax.FilterItem(filterId, #{{SearchBox_{0}}}.value.split('_')[0], selectWhere.getValue(), #{{selectbox_date_filterCondition_{0}}}.getValue(), #{{datefield_start_filterCondition_{0}}}.getRawValue(), isBetween ? #{{datefield_end_filterCondition_{0}}}.getRawValue() : ''); }} else if(type == 'numeric') {{ filterText += #{{selectbox_numeric_filterCondition_{0}}}.getRawValue(); filterText += ' '; filterText += #{{numberfield_start_numeric_{0}}}.getRawValue(); var isBetween = #{{selectbox_numeric_filterCondition_{0}}}.getValue() == 'Between'; if(isBetween) {{ filterText += ' and '; filterText += #{{numberfield_end_numeric_{0}}}.getRawValue(); }} filterItem += Ax.FilterItem(filterId, #{{SearchBox_{0}}}.value.split('_')[0], selectWhere.getValue(), #{{selectbox_numeric_filterCondition_{0}}}.getValue(), #{{numberfield_start_numeric_{0}}}.getValue(), isBetween ? #{{numberfield_end_numeric_{0}}}.getValue() : ''); }} else if(type == 'bool') {{ filterText += 'Equals '; filterText += #{{selectbox_bool_filterCondition_{0}}}.getRawValue(); filterItem += Ax.FilterItem(filterId, #{{SearchBox_{0}}}.value.split('_')[0], selectWhere.getValue(), 'Equals', #{{selectbox_bool_filterCondition_{0}}}.getValue(), ''); }} var filterItems = #{{hidden_SearchCondition_{0}}}.value; if(filterItems) filterItems += ',' + filterItem; else filterItems = filterItem; #{{hidden_SearchCondition_{0}}}.setValue(filterItems); var pnlFilterItem = new Ext.Panel({{ id:'pnlFilterItem_' + filterId, xtype:'panel', border:true, style:'float:left;' + (filterItemLength > 0 ? 'padding-left:10px;' : ''), items:[ new Ext.form.Label({{ id:'label_' + filterId, xtype:'label', text:filterText, style: 'font:11px/15px arial, tahoma, helvetica, sans-serif; background-color : #F4F4F4; padding-left:10px; padding-top:8px; padding-bottom:8px;' }}), new Ext.net.Image({{ id:'deleteIcon_' + filterId, listeners: {{ click:{{ fn:function(item,e){{ var obj = Ext.getCmp('pnlFilterItem_' + filterId); var isFirstItem = cp.items.indexOf(obj) == 0; cp.items.remove(obj); obj.destroy(); if(isFirstItem && cp.items.length > 0) {{ var pnlFltr = cp.items.first(); pnlFltr.el.dom.style.paddingLeft = ''; var lblFilter = pnlFltr.items.first(); lblFilter.setText(lblFilter.text.substring(lblFilter.text.indexOf(' ') + 1)); }} cp.doLayout(true, true); var filterObjs = eval('[' + #{{hidden_SearchCondition_{0}}}.value + ']'); var newFilterObj = ''; var filterObj; var isFirst = true; for(var i = 0; i < filterObjs.length; i++) {{ filterObj = filterObjs[i]; if(filterObj.Id == filterId) continue; newFilterObj += ((isFirst ? '' : ',') + Ax.FilterObj(filterObj)); if(isFirst) isFirst = false; }} #{{hidden_SearchCondition_{0}}}.setValue(newFilterObj); #{{{0}}}.getPagingToolbar().changePage(1); }}, delay:20 }} }}, imageUrl:'/Content/icon-cross.png', style: 'cursor:pointer; vertical-align:middle; padding-left: 5px; background-color : #F4F4F4; padding-right:8px; padding-top:6px; padding-bottom:6px;' }}) ] }}); cp.items.add(pnlFilterItem); cp.doLayout(true, true); if(!Ext.isIE) {{ pnlFilterItem.el.dom.parentNode.style['height'] = '30px'; }} #{{{0}}}.getPagingToolbar().changePage(1);", gridID); compositeField_whereCondition.Items.Add(selectBox_whereCondition); compositeField_whereCondition.Items.Add(button_search); #endregion Ext.Net.Panel panel_SearchCondition = new Ext.Net.Panel() { ID = string.Format("panel_SearchCondition_{0}", gridID), Layout = "hbox", Border = false, StyleSpec = "padding:10px;" }; Ext.Net.Label label_CrossIcon = new Ext.Net.Label() { ID = string.Format("label_loadCrossIcon_{0}", gridID), Icon = Ext.Net.Icon.Cross, Hidden = true }; Ext.Net.Hidden hidden_SearchCondition = new Ext.Net.Hidden() { ID = string.Format("hidden_SearchCondition_{0}", gridID) }; mainPanel.Items.Add(searchPanel); mainPanel.Items.Add(compositeField_whereCondition); mainPanel.Items.Add(panel_SearchCondition); mainPanel.Items.Add(label_CrossIcon); mainPanel.Items.Add(hidden_SearchCondition); Ext.Net.KeyBinding searchKey = new Ext.Net.KeyBinding(); searchKey.StopEvent = true; searchKey.Keys.Add(new Ext.Net.Key { Code = Ext.Net.KeyCode.ENTER }); searchKey.Listeners.Event.Handler = string.Format("if(#{{SearchBox_{0}}}.getValue().length > 0) {{ var btnAddFilter = #{{button_search_{0}}}; btnAddFilter.fireEvent('click', btnAddFilter); }}", gridID); mainPanel.KeyMap.Add(searchKey); #endregion Ext.Net.BorderLayout borderLayout = new Ext.Net.BorderLayout() { ID = string.Format("borderLayout_search_{0}", gridID) }; borderLayout.North.Items.Add(mainPanel); borderLayout.Center.Items.Add(grid); return borderLayout; }
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; } }
public void LoadDefaultValues() { if (SetDefaultValues) { base.Border = false; base.FileUpload = true; Ext.Net.Hidden hiddenFileID = new Ext.Net.Hidden() { ID = this.ID, Value = "" }; this.ID = this.ID + "_Form"; #region Upload HBox hBoxUploadControl = new HBox() { ID = string.Format("uploadControl_{0}", this.ID) }; // width set edilebilir olmalı Ext.Net.FileUploadField fileUpload = new Ext.Net.FileUploadField() { ID = string.Format("fileUpload_{0}", this.ID), Width = 206, Icon = Ext.Net.Icon.Attach, AllowBlank = this.AllowBlank }; Ext.Net.Button buttonUpload = new Ext.Net.Button() { ID = string.Format("buttonUpload_{0}", this.ID), Text = "Upload", StyleSpec = "padding-left:3px;", Icon = Ext.Net.Icon.FolderGo }; buttonUpload.DirectEvents.Click.Url = UploadUrl ?? "/Files/FileUpload/"; buttonUpload.DirectEvents.Click.IsUpload = true; buttonUpload.DirectEvents.Click.CleanRequest = true; buttonUpload.DirectEvents.Click.Method = Ext.Net.HttpMethod.POST; buttonUpload.DirectEvents.Click.Before = (BeforeUploadHandler ?? string.Empty) + "if (!#{" + this.ID + "}.getForm().isValid()) { return false; } Ext.Msg.wait('Uploading your file...', 'Uploading');"; buttonUpload.DirectEvents.Click.Failure = "Ext.MessageBox.hide(); if(result.errors && result.errors.length > 0) { #{" + fileUpload.ID + "}.markInvalid(result.errors[0].msg); }" + (UploadFailureHandler ?? string.Empty); buttonUpload.DirectEvents.Click.Success = string.Format(@"{6} #{{{0}}}.setValue(result.extraParams.FileID); #{{{1}}}.setText(result.extraParams.FileName); Ext.net.ResourceMgr.registerIcon(result.extraParams.Icon); #{{{1}}}.setIconClass(result.extraParams.IconCls); #{{downloadControl_{2}}}.doLayout(true, true); Ext.MessageBox.hide(); #{{{3}}}.allowBlank = true; #{{{3}}}.reset(); #{{{4}}}.hide(); #{{{5}}}.show(); ", hiddenFileID.ID, string.Format("buttonDownload_{0}", this.ID), this.ID, fileUpload.ID, hBoxUploadControl.ID, string.Format("downloadControl_{0}", this.ID), (UploadSuccessHandler ?? string.Empty)); string allowedTypes = GetFileTypes(this.FileType); if (!string.IsNullOrEmpty(allowedTypes)) this.AllowedFileTypes = allowedTypes + (!string.IsNullOrEmpty(this.AllowedFileTypes) ? "," + this.AllowedFileTypes : string.Empty); buttonUpload.DirectEvents.Click.ExtraParams.AddRange(new List<Ext.Net.Parameter>() { new Ext.Net.Parameter() { Name = "AllowedFileTypes", Value = AllowedFileTypes }, new Ext.Net.Parameter() { Name = "AllowedFileSize", Value = AllowedFileSize.ToString() }, new Ext.Net.Parameter() { Name = "FieldID", Value = fileUpload.ID }, new Ext.Net.Parameter() { Name = "FileID", Value = "0", Mode = Ext.Net.ParameterMode.Value } }); hBoxUploadControl.Items.Add(fileUpload); hBoxUploadControl.Items.Add(buttonUpload); this.Items.Add(hBoxUploadControl); #endregion #region Download HBox hBoxDownloadControl = new HBox() { ID = string.Format("downloadControl_{0}", this.ID), StyleSpec = "margin-left: -3px; margin-top: 1px;", Hidden = true }; Ext.Net.LinkButton buttonDownload = new Ext.Net.LinkButton() { ID = string.Format("buttonDownload_{0}", this.ID), Text = "Download" }; buttonDownload.DirectEvents.Click.Url = DownloadUrl ?? "/Files/FileDownload"; buttonDownload.DirectEvents.Click.CleanRequest = true; buttonDownload.DirectEvents.Click.Method = Ext.Net.HttpMethod.POST; buttonDownload.DirectEvents.Click.FormID = "proxyForm"; buttonDownload.DirectEvents.Click.IsUpload = true; buttonDownload.DirectEvents.Click.ExtraParams.Add(new Ext.Net.Parameter() { Name = "id", Value = "#{" + hiddenFileID.ID + "}.getValue()", Mode = Ext.Net.ParameterMode.Raw }); Ext.Net.ImageButton deleteButton = new Ext.Net.ImageButton() { ID = string.Format("deleteButton_{0}", this.ID), ImageUrl = "/Content/icon-cross.png", StyleSpec = "padding-left:5px;" }; StringBuilder clickHandler = new StringBuilder(); clickHandler.Append((BeforeDeleteHandler ?? string.Empty));//Before clickHandler.Append(string.Format("#{{DeletedFileIds_{0}}}.setValue(#{{DeletedFileIds_{0}}}.getValue() + #{{{0}}}.getValue() + ',');", hiddenFileID.ID)); // Click clickHandler.Append(string.Format(@"#{{{0}}}.allowBlank = {3}; #{{{0}}}.reset(); #{{{1}}}.show(); #{{{2}}}.hide(); #{{{4}}}.setValue(null); if(Ext.isIE) {{ #{{{0}}}.el.setStyle('width', '122px'); }} {5}", fileUpload.ID, hBoxUploadControl.ID, hBoxDownloadControl.ID, fileUpload.AllowBlank.ToString().ToLower(), hiddenFileID.ID, (DeleteSuccessHandler ?? string.Empty))); // Success StringBuilder sbConfirmation = new StringBuilder(); sbConfirmation.Append("var dlg = Ext.Msg.confirm('Confirm', 'Do you want to delete this file?', function (btn) { if(btn == 'yes') { " + clickHandler.ToString() + " } else { #{" + this.ID + "}.focus(); } }).getDialog();"); sbConfirmation.Append("dlg.defaultButton = 1;"); sbConfirmation.Append("dlg.focus();"); deleteButton.Listeners.Click.Handler = sbConfirmation.ToString(); hBoxDownloadControl.Items.Add(buttonDownload); hBoxDownloadControl.Items.Add(deleteButton); hBoxDownloadControl.Items.Add(hiddenFileID); hBoxDownloadControl.Items.Add(new Ext.Net.Hidden() { ID = string.Format("DeletedFileIds_{0}", hiddenFileID.ID) }); hBoxDownloadControl.Items.Add(new Ext.Net.Hidden() { ID = string.Format("DeleteUrl_{0}", hiddenFileID.ID), Value = DeleteUrl ?? "/Files/DeleteFile/" }); this.Items.Add(hBoxDownloadControl); #endregion } }