void cellInsert_Init(object sender, EventArgs e) { DataControlFieldCell cell = (DataControlFieldCell)sender; GridViewRow row = (GridViewRow)cell.NamingContainer; GridViewEx gv = (GridViewEx)row.NamingContainer; ButtonEx btn = new ButtonEx(); btn.ID = "Insert"; btn.CausesValidation = true; btn.Text = this.InsertButtonText; btn.CausesValidation = true; row.CssClass += " gvex-edit-link " + JQueryScriptManager.CssClassValidationContainer; btn.Action = ButtonAction.Submit; //TODO: Figure out what to do //btn.ValdiationContainerID = row.ID; if (!string.IsNullOrEmpty(this.CssClassInsertButton)) { btn.AddCssClass(this.CssClassInsertButton); } btn.Click += new EventHandler(btnInsert_Click); cell.Controls.Add(btn); AddCancelLink(cell, gv); }
public GridViewExDataRow(GridViewEx gv, int rowIndex, int dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState) : base(rowIndex, dataSourceIndex, rowType, rowState) { _gv = gv; // This ensures that controls within the row get unique ids this.ClientIDMode = System.Web.UI.ClientIDMode.Predictable; }
private void simpleButton1_Click(object sender, EventArgs e) { //清空APP /*APP.DataObjects.Columns.Columns.Clear(); * //checkedlist的项还原给APP * foreach (CheckedListBoxItem item in this.checkedListBoxControl1.Items) * { * APP.DataObjects.Columns.Columns.Add(item.Value); * } */ //关闭窗体刷新上一个节点 //保存配置 TreeListEx tl = this.m_Control as TreeListEx; GridViewEx gv = this.m_Control as GridViewEx; BandedGridViewEx bgv = this.m_Control as BandedGridViewEx; if (tl != null) { this.SaveColorTreeEx(tl); } if (gv != null) { this.SaveColorGridEx(gv); } if (bgv != null) { this.SaveColorGridEx(bgv); } APP.DataObjects.Save(); this.DialogResult = DialogResult.OK; }
internal override string GetClientFunction(GridViewEx gv) { string str = string.Format(@"function(keys) {{ window.location = $.validator.format('{0}', keys); }}", gv.Page.ResolveClientUrl(this.NavigateUrl)); return(str); }
internal override string GetClientFunction(GridViewEx gv) { string str = string.Format(@"function(keys) {{ var rowIndex = $(this).gridViewEx('keyIndex', keys); $(this).gridViewEx('submitForm', '{0}$' + rowIndex); }}", this.PostBackType); return(str); }
/// <summary> /// Hooks to the PreRender event of the grid. /// </summary> /// <param name="sortingEnabled"></param> /// <param name="control"></param> /// <returns></returns> public override bool Initialize(bool sortingEnabled, Control control) { _gv = (GridViewEx)control; // If we are not visible, do not modify the selectable status of the grid if (this.Visible) { _gv.Selectable.IsSelectable = true; } _gv.PreRender += new EventHandler(_gv_PreRender); return(base.Initialize(sortingEnabled, control)); }
/// <summary> /// When we are exporting to excel, OnPreRender() is not called. In this case our <see cref="RowIndex"/> /// remains <c>ROW_SINGLE_LINE_HEADER</c>. /// Excel cannot tolerate multiple line headers. /// </summary> /// <param name="e"></param> protected override void OnPreRender(EventArgs e) { _rowIndex = ROW_FIRST_LINE_HEADER; base.OnPreRender(e); GridViewEx gv = (GridViewEx)this.NamingContainer; _newRow = FormatMultiRowHeader(gv); if (_newRow != null) { _newRow.CssClass = gv.HeaderStyle.CssClass; } }
void gv_PreRender(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.DeleteConfirmationText)) { GridViewEx gv = (GridViewEx)sender; string script = string.Format(@"$('#{0} a.gvex-delete-link') .unbind('click.CommandFieldEx') .bind('click.CommandFieldEx', function(e) {{ return confirm($(this).attr('title') + ' Press Ok to confirm.'); }});", gv.ClientID); JQueryScriptManager.Current.RegisterReadyScript(script); } }
public GridViewExMasterRow(GridViewEx gv, int rowIndex, int dataItemIndex, DataControlRowState rowState) : base(gv, rowIndex, dataItemIndex, DataControlRowType.DataRow, rowState) { _rowInfo._countRowsInMaster = 1; if (rowIndex == 0) { // This is the first master row. Hook up to grid's events. gv.RowDataBound += new GridViewRowEventHandler(gv_RowDataBound); gv.DataBound += new EventHandler(gv_DataBound); // Start by assuming that we are the last detail row _lastDetailRow = this; } }
void btnUpdate_Click(object sender, EventArgs e) { ButtonEx btn = (ButtonEx)sender; GridViewRow row = (GridViewRow)btn.NamingContainer; GridViewEx gv = (GridViewEx)row.NamingContainer; if (!btn.IsPageValid()) { return; } else { gv.UpdateRow(row.RowIndex, false); } }
/// <summary> /// Make ourselves a master row. This event is only expected to be received by the last master row. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void gv_DataBound(object sender, EventArgs e) { GridViewEx gv = this.Grid; _lastDetailRow._subtotalInfo = _subtotalInfo; _subtotalInfo = null; if (_markupComparer != null) { _markupComparer.Dispose(); _markupComparer = null; } // Tell sequence fields to not use page index while computing row sequence gv.Columns.Cast <DataControlField>() .OfType <SequenceField>().ToList().ForEach(p => p.UsePageIndex = false); }
protected override void Render(HtmlTextWriter writer) { GridViewEx gv = (GridViewEx)this.NamingContainer; // This takes care of the possibility of a MatrixField existing as one of the columns int visibleColumnCount = gv.HeaderRow.Cells.Cast <DataControlFieldHeaderCell>() .Where(p => p.Visible) .Aggregate(0, (total, next) => total + (next.ColumnSpan == 0 ? 1 : next.ColumnSpan)); writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.AddAttribute(HtmlTextWriterAttribute.Colspan, visibleColumnCount.ToString()); writer.AddAttribute(HtmlTextWriterAttribute.Class, "gvex-pager-cell"); writer.RenderBeginTag(HtmlTextWriterTag.Td); RenderContents(writer); writer.RenderEndTag(); // td writer.RenderEndTag(); // tr }
private void AddCancelLink(DataControlFieldCell cell, GridViewEx gv) { Literal lit = new Literal(); lit.Text = "<br/>"; cell.Controls.Add(lit); HyperLink hlCancel = new HyperLink(); //hlCancel.NavigateUrl = string.Format("javascript:gridviewex_submit('{0}', '{1}', 'Cancel${2}')", // cell.Page.Form.ClientID, gv.UniqueID, cell.Text); hlCancel.Text = this.CancelLinkText; hlCancel.NavigateUrl = "#"; hlCancel.CssClass = "gvex-cancel-link"; cell.Controls.Add(hlCancel); }
/// <summary> /// Generates the options which need to be passed to the jQuery <c>selectable</c> widget. /// </summary> /// <param name="owner"></param> /// <param name="gridOptions"></param> internal void MakeSelectable(GridViewEx owner, JQueryOptions gridOptions) { if (!this.IsSelectable) { return; } JQueryOptions selectableOptions = new JQueryOptions(); if (owner.EnableViewState) { gridOptions.Add("enableClientState", true); } //options.Add("autoRefresh", false); selectableOptions.Add("filter", this.Filter); selectableOptions.Add("tolerance", "touch"); // Multiple selection will not start until the mouse is dragged beyond these many pixels //options.Add("distance", 8); if (string.IsNullOrEmpty(this.Cancel)) { // If any of the header rows is clicked, do not modify selection selectableOptions.Add("cancel", ":input,option,a[href], tr.gvex-masterrow *, tr.gvex-subtotal-row *, thead *, tfoot *"); } else { selectableOptions.Add("cancel", this.Cancel); } if (!string.IsNullOrEmpty(this.OnSelectableStop)) { //options.AddRaw("stop", this.OnSelectableStop); owner.ClientEvents.Add("selectablestop", this.OnSelectableStop); } if (!string.IsNullOrEmpty(this.OnSelectableSelecting)) { owner.ClientEvents.Add("selectableselecting", this.OnSelectableSelecting); } if (!string.IsNullOrEmpty(this.OnSelectableUnselected)) { owner.ClientEvents.Add("selectableunselected", this.OnSelectableUnselected); } if (!string.IsNullOrEmpty(this.OnSelectableSelected)) { owner.ClientEvents.Add("selectableselected", this.OnSelectableSelected); } gridOptions.Add("selectable", selectableOptions); }
protected override void OnInit(EventArgs e) { if (this.GridViewExId.Contains("$")) { string[] tokens = GridViewExId.Split('$'); Control ctl = this.NamingContainer; foreach (string token in tokens) { ctl = ctl.FindControl(token); } _gv = (GridViewEx)ctl; } else { _gv = (GridViewEx)this.NamingContainer.FindControl(this.GridViewExId); } base.OnInit(e); }
/// <summary> /// Hook up the row data bound and pre render events of the grid /// </summary> /// <param name="sortingEnabled">Not used</param> /// <param name="control">This must be of type <see cref="GridViewEx"/>.</param> /// <returns></returns> public override bool Initialize(bool sortingEnabled, Control control) { _gv = (GridViewEx)control; if (this.MatrixColumns.Count == 0) { // Add a default column this.MatrixColumns.Add(new MatrixColumn()); } foreach (var mc in this.MatrixColumns.Where(p => p.ColumnType == MatrixColumnType.RowTotal)) { MatrixDisplayColumn info = new MatrixDisplayColumn(this, mc, -1); _displayColumns.Add(info); } return(base.Initialize(sortingEnabled, control)); }
void cellEdit_Init(object sender, EventArgs e) { DataControlFieldCell cell = (DataControlFieldCell)sender; GridViewRow row = (GridViewRow)cell.NamingContainer; GridViewEx gv = (GridViewEx)row.NamingContainer; ButtonEx btn = new ButtonEx(); btn.ID = "Update"; btn.CausesValidation = true; btn.Action = ButtonAction.Submit; btn.Text = this.UpdateButtonText; btn.CausesValidation = true; // row.ID is always null row.CssClass += " gvex-edit-link " + JQueryScriptManager.CssClassValidationContainer; btn.Click += new EventHandler(btnUpdate_Click); cell.Controls.Add(btn); AddCancelLink(cell, gv); }
/// <summary> /// 保存表格列Ex颜色方案 /// </summary> /// <param name="p_GridEx"></param> private void SaveColorGridEx(GridViewEx p_Grid) { //若不存在 if (APP.DataObjects.GColor.ColumnColor == null) { APP.DataObjects.GColor.ColumnColor = new _ColumnColor(); } //初始化模块(不存在则新增) APP.DataObjects.GColor.ColumnColor.Init(p_Grid.ModelName); //若是第一次使用列配色 //APP.DataObjects.GColor.ColumnColor.Set(p_Tree.ModelName,); foreach (GridColumn col in p_Grid.Columns) { _CellStyle stype = new _CellStyle(); stype.BColor = col.AppearanceCell.BackColor; //保存颜色 APP.DataObjects.GColor.ColumnColor[p_Grid.ModelName].Set(col.FieldName, stype); } }
/// <summary> /// If multiple rows are necessary, the passed row becomes the current row becomes the first row. /// The new row is returned. /// </summary> /// <param name="gv"></param> /// <returns></returns> private GridViewRow FormatMultiRowHeader(GridViewEx gv) { // Start by assuming that we will need a new row // Set row index to -2 to indicate that this is the second header row. // GridViewMatrixCell looks at this to determine whether the first row or the second row of the header should // be rendered GridViewRow rowAdded = new GridViewRow(ROW_SECOND_LINE_HEADER, -1, DataControlRowType.Header, DataControlRowState.Normal); for (int i = 0; i < this.Cells.Count; ++i) { DataControlFieldCell cellOrig = (DataControlFieldCell)this.Cells[i]; if (!cellOrig.ContainingField.Visible) { // Ignore invisible columns continue; } char[] seperator = new char[] { '|' }; string[] tokens = cellOrig.ContainingField.HeaderText.Split(seperator, StringSplitOptions.RemoveEmptyEntries); //string[] expressions = gv.SortExpression.Split(';'); //List<string> listSortExpressions = new List<string>(expressions); switch (tokens.Length) { case 0: // Empty header cellOrig.RowSpan = 2; break; case 1: // single line header cellOrig.RowSpan = 2; cellOrig.VerticalAlign = VerticalAlign.Middle; cellOrig.Text = tokens[0]; break; case 2: // Tow header rows are in fact needed cellOrig.Text = tokens[0]; DataControlFieldCell cellNew; if (cellOrig.ContainingField is IHasCustomCells) { IHasCustomCells cancreate = cellOrig.ContainingField as IHasCustomCells; cellNew = cancreate.CreateCell(DataControlCellType.Header); } else { cellNew = new GridViewExHeaderCell(gv, cellOrig.ContainingField); } cellNew.Text = tokens[1]; rowAdded.Cells.Add(cellNew); break; default: throw new NotSupportedException("At most one pipe character is allowed in the header text"); } } if (rowAdded.Cells.Count == 0) { // Revert all the rowspans back to default foreach (TableCell cell in this.Cells) { cell.RowSpan = 0; } rowAdded = null; } else { SetColumnSpan(); } return(rowAdded); }
internal abstract string GetClientFunction(GridViewEx gv);
/// <summary> /// If a detail row belonging to the next master is encountered, finalize our master status by /// creating _dictMasterCells. Unhook all grid events and hook them to the new master. /// </summary> /// <remarks> /// The function checks mark up of rows, if markup is not same this states that master is not same for both hence renders /// master row. Since this is a special row so we have to explicitly unhook to <see cref="GridViewEx" /> <c>RowDataBound</c> /// and <c>DataBound</c> events, then calling <c>InitializeSubTotals</c> for initializing master columns and after this the /// class again hooks to <c>GridViewEx</c> <c>RowDataBound</c> and <c>DataBound</c> events. If markups are same then the /// function perfoms row counts and summasion for all the child columns. /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void gv_RowDataBound(object sender, GridViewRowEventArgs e) { if (!e.Row.Visible) { // Ignore return; } GridViewEx gv = this.Grid; GridViewExMasterRow row = e.Row as GridViewExMasterRow; if (row == null) { // Do nothing. This must be a normal row return; } // Sharad 26 Feb 2010: Checking this.RowIndex instead of this.DataItemIndex to avoid special situation bug of // subtotal and total // GL 11 June, 2010: Now checking row.DataItemIndex instead of row.RowIndex as this was resulting into // erronous sequencing in master-details reports when it was required to have new sequence for every master. if (row.DataItemIndex == this.RowIndex) { // First row of the master. Simply Initialize totals. We get here only for the very first master row. InitializeSubTotals(e.Row.DataItem, e.Row.RowIndex); return; } // e.Row is one of the detail rows or a new master row switch (e.Row.RowType) { case DataControlRowType.DataRow: if (_markupComparer == null) { _markupComparer = new ControlMarkupComparer(); } if (gv.MasterColumnIndexes.Any(p => !_markupComparer.MarkupSame( this.Cells[p], e.Row.Cells[p]))) { // First row of this master gv.RowDataBound -= gv_RowDataBound; gv.DataBound -= gv_DataBound; row._rowInfo._masterRowIndex = _rowInfo._masterRowIndex + 1; row._markupComparer = _markupComparer; row._lastDetailRow = row; row._rowInfo._indexWithinMaster = 0; row.InitializeSubTotals(row.DataItem, row.DataItemIndex); // first row of master is handing over the subtotals to the last row. // The last row will be responsible for displaying them. _lastDetailRow._subtotalInfo = _subtotalInfo; _subtotalInfo = null; gv.RowDataBound += row.gv_RowDataBound; gv.DataBound += row.gv_DataBound; } else { // Subsequent row of this master _lastDetailRow = row; row._rowInfo._indexWithinMaster = this._rowInfo._countRowsInMaster; ++_rowInfo._countRowsInMaster; _subtotalInfo.LastRowIndex = row.DataItemIndex; var query = gv.Columns.Cast <DataControlField>() .Select((p, i) => new { Column = p as INeedsSummaries, Index = i }) .Where(p => p.Column != null); foreach (var colInfo in query) { switch (colInfo.Column.DataSummaryCalculation) { case SummaryCalculationType.None: case SummaryCalculationType.DataSource: // No subtotals break; case SummaryCalculationType.ValueSummation: case SummaryCalculationType.ValueWeightedAverage: SummaryData data = _subtotalInfo.Subtotals[colInfo.Index]; for (int i = 0; i < colInfo.Column.DataFooterFields.Length; ++i) { object obj = DataBinder.Eval(e.Row.DataItem, colInfo.Column.DataFooterFields[i]); if (obj != DBNull.Value) { if (data.Values[i] == null) { data.Values[i] = Convert.ToDecimal(obj); } else { data.Values[i] += Convert.ToDecimal(obj); } ++data.RowCount; } } break; default: throw new NotImplementedException(); } } } break; } }
internal override string GetClientFunction(GridViewEx gv) { return(this.OnClientClick); }
private void GridViewEx_PreparingContainerForItem(object sender, GridViewEx.PreparingContainerForItemEventArgs e) { try { dynamic data = e.Item; e.Element.SetValue(Windows.UI.Xaml.Controls.VariableSizedWrapGrid.ColumnSpanProperty, data.ColumnSpan); } catch { e.Element.SetValue(Windows.UI.Xaml.Controls.VariableSizedWrapGrid.ColumnSpanProperty, 1); } }
protected override void RenderContents(HtmlTextWriter writer) { GridViewEx gv = (GridViewEx)this.NamingContainer; string str; if (!_isFirstPage) { writer.AddStyleAttribute("float", "left"); writer.AddAttribute(HtmlTextWriterAttribute.Class, "gvex-page-link ui-icon ui-icon-seek-first"); writer.AddAttribute(HtmlTextWriterAttribute.Title, "First Page"); str = string.Format("1${0}", gv.DefaultSortExpression); writer.AddAttribute(HtmlTextWriterAttribute.Href, str); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.RenderEndTag(); writer.AddStyleAttribute("float", "left"); str = string.Format("{0}${1}", gv.PageIndex, gv.DefaultSortExpression); writer.AddAttribute(HtmlTextWriterAttribute.Href, str); writer.AddAttribute(HtmlTextWriterAttribute.Class, "gvex-page-link ui-icon ui-icon-seek-prev"); writer.AddAttribute(HtmlTextWriterAttribute.Title, "Previous Page"); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.RenderEndTag(); } if (!_isLastPage) { writer.AddStyleAttribute("float", "right"); writer.AddAttribute(HtmlTextWriterAttribute.Class, "gvex-page-link ui-icon ui-icon-seek-end"); writer.AddAttribute(HtmlTextWriterAttribute.Title, "Last Page"); str = string.Format("{0}${1}", _pageCount, gv.DefaultSortExpression); writer.AddAttribute(HtmlTextWriterAttribute.Href, str); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.RenderEndTag(); writer.AddStyleAttribute("float", "right"); str = string.Format("{0}${1}", gv.PageIndex + 2, gv.DefaultSortExpression); writer.AddAttribute(HtmlTextWriterAttribute.Href, str); writer.AddAttribute(HtmlTextWriterAttribute.Class, "gvex-page-link ui-icon ui-icon-seek-next"); writer.AddAttribute(HtmlTextWriterAttribute.Title, "Next Page"); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.RenderEndTag(); } //writer.Write("Displaying {0:N0} - {1:N0} of {2:N0} results • ", // (gv.PageIndex * gv.PageSize) + 1, // (gv.PageIndex + 1) * gv.PageSize - (gv.PageSize - gv.Rows.Count), // _totalRows); writer.Write("Displaying {0:N0} to {1:N0} of ", (gv.PageIndex * gv.PageSize) + 1, (gv.PageIndex + 1) * gv.PageSize - (gv.PageSize - gv.Rows.Count)); writer.AddStyleAttribute(HtmlTextWriterStyle.FontWeight, "bold"); writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, "1.2em"); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write("{0:N0} ", _totalRows); writer.RenderEndTag(); // span writer.Write("results • "); const int MAX_NUMERIC_BUTTONS = 10; int nFirstButtonPageIndex = gv.PageIndex - (gv.PageIndex % MAX_NUMERIC_BUTTONS); int nLastButtonPageIndex = Math.Min(_pageCount - 1, nFirstButtonPageIndex + MAX_NUMERIC_BUTTONS); for (int i = nFirstButtonPageIndex; i <= nLastButtonPageIndex; ++i) { if (i == gv.PageIndex) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "ui-state-active"); } else { str = string.Format("{0}${1}", i + 1, gv.DefaultSortExpression); writer.AddAttribute(HtmlTextWriterAttribute.Class, "gvex-page-link"); writer.AddAttribute(HtmlTextWriterAttribute.Href, str); } writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write(i + 1); writer.RenderEndTag(); //a writer.Write(" "); } return; }
public GridViewExHeaderCell(GridViewEx gv, DataControlField containingField) : base(containingField) { _gv = gv; }