//queries the column descriptor and statically constructs the desired //renderer. A better implementation would construct the renderer dynamically, //via reflection to make the mechanizm highly extendable, as then you wouldn't //be constrained to use only existing renderers. public IGINColumnRenderer CreateRenderer(GINColumnDescriptor column) { switch (column.Renderer) { case "LinkGINColumnRenderer": return(new LinkGINColumnRenderer(column)); case "CheckBoxGINColumnRenderer": return(new CheckBoxGINColumnRenderer(column)); case "DateTimeGINColumnRenderer": return(new DateTimeGINColumnRenderer(column)); case "DateAndTimeGINColumnRenderer": return(new DateAndTimeGINColumnRenderer(column)); default: return(new GINColumnRenderer(column)); } }
public void Setup() { string validationGroup = string.Empty; if (!driver.SuppressValidationSummary) { validationGroup = (driver.ValidationGroup == null || driver.ValidationGroup == string.Empty) ? driver.Title : driver.ValidationGroup; } ValidationMessage.ValidationGroup = validationGroup; btnOk.ValidationGroup = validationGroup; List <TableRow> rowsToRemove = new List <TableRow>(); foreach (TableRow tableRow in RenderTable.Rows) { if ((tableRow.ID != "CaptionRow") && (tableRow.ID != "CommandRow") && (tableRow.ID != "MessageRow")) { rowsToRemove.Add(tableRow); } } foreach (TableRow tableRow in rowsToRemove) { RenderTable.Rows.Remove(tableRow); } ExtenderPanel.Controls.Clear(); //foreach (GINColumnDescriptor column in driver.Columns) var nonCascadingColumns = from column in driver.Columns where column.IsViewable && (from child in driver.Columns select child).All(child => !child.IsCascadedLookup || (child.IsCascadedLookup && (child.ParentLookup != column.Name))) select column; foreach (GINColumnDescriptor column in nonCascadingColumns) { if (column.IsCDDExtender) { //string parentColumnName = (from pcr in column.ExtendedColumns where pcr.Role=="Parent" select pcr.Name).Single(); //GINColumnDescriptor parentColumn = driver.Columns.Find(parent=>parent.Name == parentColumnName); //string childColumnName = (from pcr in column.ExtendedColumns where pcr.Role=="Child" select pcr.Name).Single(); //GINColumnDescriptor childColumn = driver.Columns.Find(child=>child.Name == childColumnName); //CascadingDropDown cddExtender = new CascadingDropDown(); //cddExtender.ID = string.Format("cddExtender_{0}", column.Name); //cddExtender.Category = parentColumn.Lookup; //cddExtender.Enabled = true; //cddExtender.LoadingText = "Please wait..."; //Control childContainingControl = FindCell(string.Format("ddl{0}", childColumnName)); //cddExtender.ParentControlID = string.Format("ddl{0}", parentColumnName); //cddExtender.TargetControlID = string.Format("ddl{0}", childColumnName); //cddExtender.ServicePath = column.ServicePath; //cddExtender.ServiceMethod = column.ServiceMethod; //childContainingControl.Controls.Add(cddExtender); GINColumnDescriptorReference parentReference = (from pcr in column.ExtendedColumns where pcr.Role == "Parent" select pcr).Single(); string parentColumnName = parentReference.Name; GINColumnDescriptor parentColumn = driver.Columns.Find(parent => parent.Name == parentColumnName); string childColumnName = (from pcr in column.ExtendedColumns where pcr.Role == "Child" select pcr.Name).Single(); GINColumnDescriptor childColumn = driver.Columns.Find(child => child.Name == childColumnName); CascadingDropDown cddExtender = new CascadingDropDown(); cddExtender.ID = string.Format("cddExtender_{0}", childColumnName); if ((parentColumn == null) && (parentReference.UseContextKey)) { cddExtender.ContextKey = lookup.GetLookup(parentReference.ContextKeyLookup)[parentReference.ContextKeyName]; } cddExtender.Category = (parentColumn == null)?"undefined":parentColumn.Lookup; cddExtender.Enabled = true; cddExtender.LoadingText = "Please wait..."; cddExtender.PromptText = string.Format("[select {0}]", childColumnName); cddExtender.PromptValue = DALManager.NullFinder.GetNullValue(childColumn.DataType).ToString(); Control childContainingControl = FindCell(string.Format("ddl{0}", childColumnName)); if (parentColumnName != string.Empty) { cddExtender.ParentControlID = string.Format("ddl{0}", parentColumnName); } cddExtender.TargetControlID = string.Format("ddl{0}", childColumnName); cddExtender.ServicePath = column.ServicePath; cddExtender.ServiceMethod = column.ServiceMethod; cddExtender.DataBinding += new EventHandler(cddExtender_DataBinding); childContainingControl.Controls.Add(cddExtender); continue; } if (column.IsTextChangeExtender) { string publisherColumnName = (from pcr in column.ExtendedColumns where pcr.Role == "Publisher" select pcr.Name).Single(); TextBox txtPublisher = (TextBox)FindColumnControl(string.Format("txt{0}", publisherColumnName)); txtPublisher.AutoPostBack = true; txtPublisher.TextChanged += new EventHandler(txtPublisher_TextChanged); UpdatePanelControlTrigger trigger = new AsyncPostBackTrigger(); trigger.ControlID = txtPublisher.ID; TextChangeUpdatePanel.Triggers.Add(trigger); continue; } TableRow row = new TableRow(); int index = RenderTable.Rows.Count - 1; RenderTable.Rows.AddAt(index, row); TableCell cell = new TableCell(); if (index % 2 == 0) { cell.CssClass = alternateRowClass; } cell.Width = new Unit(35, UnitType.Percentage); row.Cells.Add(cell); Literal caption = new Literal(); caption.Text = column.Header; cell.Controls.Add(caption); cell = new TableCell(); if (index % 2 == 0) { cell.CssClass = alternateRowClass; } cell.Width = new Unit(65, UnitType.Percentage); row.Cells.Add(cell); if (column.IsCascadedLookup) { GINColumnDescriptor parentColumn = driver.Columns.Find(parent => parent.Name == column.ParentLookup); IGINColumnRenderer renderer = parentColumn.AttachedRenderer; if (parentColumn.IsLookup) { renderer.Lookup = Lookup; } renderer.DataSource = DataSource; WebControl parentControl = renderer.RenderInEditor(); parentControl.ID = string.Format("cddParent_{0}", parentColumn.Name); parentControl.Width = new Unit(50, UnitType.Percentage); renderer = column.AttachedRenderer; renderer.DataSource = DataSource; WebControl childControl = renderer.RenderInEditor(); childControl.ID = string.Format("cddChild_{0}", column.Name); childControl.Width = new Unit(50, UnitType.Percentage); Panel uPan = new Panel(); uPan.Controls.Add(parentControl); uPan.Controls.Add(childControl); CascadingDropDown cddExtender = new CascadingDropDown(); cddExtender.ID = string.Format("cddExtender_{0}", column.Name); cddExtender.Category = parentColumn.Lookup; cddExtender.LoadingText = "Please wait..."; cddExtender.ParentControlID = parentControl.ID; cddExtender.TargetControlID = childControl.ID; cddExtender.ServicePath = column.ServicePath; cddExtender.ServiceMethod = column.ServiceMethod; uPan.Controls.Add(cddExtender); cell.Controls.Add(uPan); row.Cells.Add(cell); } else { IGINColumnRenderer renderer = column.AttachedRenderer; if (column.IsLookup) { renderer.Lookup = Lookup; } renderer.DataSource = DataSource; WebControl ctrl = renderer.RenderInEditor(); List <BaseValidator> validators = SetValidationGroup(ctrl); cell.Controls.Add(ctrl); cell = new TableCell(); foreach (BaseValidator validator in validators) { cell.Controls.Add(validator); //ctrl.Controls.Remove(validator); } row.Cells.Add(cell); } } }
public GINColumnRenderer(GINColumnDescriptor column) { this.column = column; }
public IGINColumnRenderer GetRenderer(GINColumnDescriptor column) { return(this.rendererGenerator.CreateRenderer(column)); }
public DateAndTimeGINColumnRenderer(GINColumnDescriptor column) : base(column) { }
public CheckBoxGINColumnRenderer(GINColumnDescriptor column) : base(column) { }
public LinkGINColumnRenderer(GINColumnDescriptor column) : base(column) { }