internal override void RenderLabelView(WebGridHtmlWriter writer, RowCell cell) { if (cell.Value != null && Visibility != Visibility.None) { writer.Write(RenderTemplate(cell)); } }
internal static void AddClientScript(WebGridHtmlWriter writer, string scriptcontent) { if (Anthem.Manager.IsCallBack) { Anthem.Manager.AddScriptForClientSideEval(scriptcontent); } else { writer.Write(string.Format(@"<script type=""text/javascript"">{0}</script>", scriptcontent)); } }
internal override void RenderEditView(WebGridHtmlWriter writer, RowCell cell) { if (Grid.InternalId == null) { return; } if (GridObject == null) { throw new ApplicationException( string.Format("Grid '{0}' Not found for column '{1}' in grid '{2}'", GridId, Title, Grid.Title)); } Grid.m_HasGridInsideGrid = true; GridObject.m_IsGridInsideGrid = true; GridObject.m_EventRanDoRender = false; StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); System.Web.UI.HtmlTextWriter gridwriter = new System.Web.UI.HtmlTextWriter(sw); GridObject.RenderControl(gridwriter); GridObject.m_EventRanDoRender = true; writer.Write(sb); }
// 2005.01.09 - jorn - String.Compare, string.Length // 2005.01.05 - Jorn - Added check to see if there actually is a checkbox on "previous page". // Need to add a hidden field since checkbox "returns null" both for unchecked and non-existing internal void RenderDetail(bool enabled, WebGridHtmlWriter writer, RowCell cell) { if (AllowEdit == false || (Grid.DisplayView == DisplayView.Grid && AllowEditInGrid == false)) { enabled = false; } string uniqueId = cell.CellClientId; string strValue = DisplayText(cell); const string checkedValue = TrueValue; const string uncheckedValue = FalseValue; StringBuilder sb; if (String.Compare(strValue, checkedValue, true) == 0 && CheckedAlias != null && enabled == false) { sb = new StringBuilder(CheckedAlias); } else if (String.Compare(strValue, uncheckedValue, true) == 0 && UncheckedAlias != null && enabled == false) { sb = new StringBuilder(UncheckedAlias); } else { string bitchecked = string.Empty; string bitEnabled = string.Empty; if (String.Compare(strValue, checkedValue, true) == 0) { bitchecked = " checked=\"checked\""; } if (enabled == false) { bitEnabled = " disabled=\"disabled\""; } StringBuilder javascript = new StringBuilder(string.Empty); StringBuilder onblur = new StringBuilder(" onblur=\""); if (Grid.InputHighLight != Color.Empty) { javascript.AppendFormat( " onfocus=\"this.accessKey = this.style.backgroundColor;this.style.backgroundColor='{0}';\"", Grid.ColorToHtml(Grid.InputHighLight)); onblur.Append("this.style.backgroundColor=this.accessKey;"); } if (Grid.ColumnChangedColour != Color.Empty) { onblur.AppendFormat("isChanged(this,'{0}');", Grid.ColorToHtml(Grid.ColumnChangedColour)); } onblur.Append("\""); if (AutoPostback || string.IsNullOrEmpty(ConfirmMessage) == false) { StringBuilder eventScript = new StringBuilder(" onclick=\""); if (string.IsNullOrEmpty(ConfirmMessage) == false) { eventScript.AppendFormat(" if(wgconfirm('{0}',this,'{1}')) ", ConfirmMessage.Replace("'", "\\'"), Grid.DialogTitle.Replace("'", "\\'")); } string link = Grid.EnableCallBack && !ForcePostBack?Asynchronous.GetCallbackEventReference(Grid, string.Format("ElementPostBack!{0}!{1}", ColumnId, cell.Row.PrimaryKeyValues), false, string.Empty, string.Empty) : Grid.Page.ClientScript.GetPostBackEventReference(Grid, string.Format( "ElementPostBack!{0}!{1}", ColumnId, cell.Row.PrimaryKeyValues)); eventScript.AppendFormat("{0}\"", link); javascript.Append(eventScript); } javascript.Append(onblur); sb = new StringBuilder( string.Format( "<input {0} type=\"checkbox\" {1} {2} {4} id=\"cb_{3}\" name=\"{3}\" value=\"1\"/>", javascript, bitchecked, bitEnabled, uniqueId, Attributes)); if (string.IsNullOrEmpty(m_Displaylabel) == false) { sb.AppendFormat( "<label class=\"wglabel\" id=\"label_{0}\" for=\"cb_{0}\">{1}</label>", uniqueId, m_Displaylabel); } if (enabled) { writer.Write("<input type=\"hidden\" id=\"{0}_cb\" name=\"{0}_cb\" value=\"{1}\" />", uniqueId, checkedValue); } } if (string.IsNullOrEmpty(ToolTipInput) == false) { sb = new StringBuilder(Tooltip.Add(sb.ToString(), ToolTipInput)); } EditHtml(sb.ToString(), writer, cell); }
internal override void RenderLabelView(WebGridHtmlWriter writer, RowCell cell) { if (cell == null) { return; } switch (SystemColumnType) { case Enums.SystemColumn.PagerColumn: if (Grid.RecordCount > Grid.PageSize) { return; } cell.Row.m_Table.m_Grid.PagerSettings.SliderOperation = System.Web.UI.WebControls.Orientation.Vertical; writer.Write(cell.Row.m_Table.m_Grid.PagerSettings.GetPager); cell.Row.m_Table.m_Grid.PagerSettings.PagerType = PagerType.None; break; case Enums.SystemColumn.SelectColumn: writer.Write( SelectableRows.GetItemCheckbox(Grid, cell.Row.PrimaryKeyValues, string.Empty, Grid.ColorToHtml(Grid.SelectRowColor))); break; case Enums.SystemColumn.DeleteColumn: if (cell.Row.AllowDelete == false) { Visibility = Visibility.None; Title = null; } else { string strConfirmDelete = Grid.GetSystemMessage("ConfirmDelete"); if (Html == null) { writer.Write(Buttons.Anchor(Grid, " ", "RecordDeleteClick", new[] { cell.Row.PrimaryKeyValues }, strConfirmDelete, Grid.GetSystemMessage("DeleteRow"), "ui-icon ui-icon-trash", null, false)); } else { writer.Write( Buttons.TextButtonControl(Grid, Html, "RecordDeleteClick", new[] { cell.Row.PrimaryKeyValues }, null, strConfirmDelete)); } } break; case Enums.SystemColumn.SpacingColumn: WidthColumnHeaderTitle = System.Web.UI.WebControls.Unit.Empty; writer.Write(" "); break; case Enums.SystemColumn.CopyColumn: if (cell.Row.AllowCopy == false) { Visibility = Visibility.None; Title = null; } else { const string strConfirmCopy = null; if (Html == null) { writer.Write( Buttons.Anchor(Grid, " ", "RecordCopyClick", new[] { string.Empty, cell.Row.PrimaryKeyValues }, strConfirmCopy, Grid.GetSystemMessage("CopyRow"), "ui-icon ui-icon-copy", null, false)); } else { writer.Write( Buttons.TextButtonControl(Grid, Html, "RecordCopyClick", new[] { string.Empty, cell.Row.PrimaryKeyValues }, null, strConfirmCopy)); } } break; case Enums.SystemColumn.NewRecordColumn: if (Grid.AllowNew == false) { Visibility = Visibility.None; Title = null; } else { if (Html == null) { writer.Write( Buttons.TextButtonControl(Grid, Grid.GetSystemMessage("NewRecord"), "NewRecordClick", new string[] { }, Grid.GetSystemMessageClass("NewRecord", "wgnewrecord"))); } else { writer.Write( Buttons.TextButtonControl(Grid, Html, "NewRecordClick", new string[] { }, Grid.GetSystemMessageClass("NewRecord", "wgnewrecord"))); } } break; case Enums.SystemColumn.UpdateGridRecordsColumn: if (Grid.AllowUpdate == false) { Visibility = Visibility.None; Title = null; } else { if (Html == null) { writer.Write( Buttons.TextButtonControl(Grid, Grid.GetSystemMessage("UpdateRows"), "UpdateRowsClick", new string[] { }, Grid.GetSystemMessageClass("UpdateRows", "wgUpdateRows"))); } else { writer.Write( Buttons.TextButtonControl(Grid, Html, "UpdateRowsClick", new string[] { }, Grid.GetSystemMessageClass("UpdateRows", "wgUpdateRows"))); } } break; case Enums.SystemColumn.UpdateGridRecordColumn: if (Grid.AllowUpdate == false) { Visibility = Visibility.None; Title = null; } else { StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); System.Web.UI.HtmlTextWriter textwriter = new System.Web.UI.HtmlTextWriter(sw); if (Html == null) { textwriter.Write(Buttons.TextButtonControl(Grid, Grid.GetSystemMessage("UpdateRow"), "UpdateRowClick", new[] { cell.Row.PrimaryKeyValues }, Grid.GetSystemMessageClass("UpdateRow", "wgUpdateRow"))); } else { textwriter.Write(Buttons.TextButtonControl(Grid, Html, "UpdateRowClick", new[] { cell.Row.PrimaryKeyValues }, Grid.GetSystemMessageClass("UpdateRow", "wgUpdateRow"))); } writer.Write(sb); } break; } // base.RenderLabelView(writer,cell); RenderGrid(null, writer, cell); }
private void ApplyInternalValues(RowCell cell, Control ctrl) { foreach (Control control in ctrl.Controls) { if (control is LiteralControl == false) { continue; } LiteralControl ctr = control as LiteralControl; if (ctr == null) { continue; } string innerhtml = ctr.Text; if (!string.IsNullOrEmpty(innerhtml) && innerhtml.IndexOf(string.Format("[{0}]", ColumnId), StringComparison.OrdinalIgnoreCase) != -1) { throw new GridException( string.Format("The template '{0}' can't contain reference to itself.", ColumnId)); } if (string.IsNullOrEmpty(innerhtml) || !innerhtml.Contains("[")) { continue; } string content = innerhtml; cell.Row.Columns.ForEach(delegate(Column column) { if ( content.IndexOf(string.Format("[{0}]", column.ColumnId), StringComparison.OrdinalIgnoreCase) == -1) { return; } WebGridHtmlWriter writer = new WebGridHtmlWriter(Grid); Visibility columnvisibility = column.Visibility; column.Visibility = Visibility; column.SystemMessageStyle = SystemMessageStyle.WebGrid; if (Grid.Trace.IsTracing) { Grid.Trace.Trace( "Rendering ColumnName: {0} in column: {1}", column.ColumnId, ColumnId); } column.RenderEditView(writer, cell.Row.Cells[column.ColumnId]); column.Visibility = columnvisibility; if (column.AllowEdit) { writer.Write( "<input type=\"hidden\" value=\"validate\" name=\"{0}_{1}_validate\" />", Grid.ClientID, column.ColumnId); } content = content.Replace(string.Format("[{0}]", column.ColumnId), writer.ToString()); }); ((LiteralControl)control).Text = content; } }
internal override void RenderEditView(WebGridHtmlWriter writer,RowCell cell) { if (Grid.InternalId == null) return; if (GridObject == null) throw new ApplicationException( string.Format("Grid '{0}' Not found for column '{1}' in grid '{2}'", GridId, Title, Grid.Title)); Grid.m_HasGridInsideGrid = true; GridObject.m_IsGridInsideGrid = true; GridObject.m_EventRanDoRender = false; StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); System.Web.UI.HtmlTextWriter gridwriter = new System.Web.UI.HtmlTextWriter(sw); GridObject.RenderControl(gridwriter); GridObject.m_EventRanDoRender = true; writer.Write(sb); }