protected override void OnInit(EventArgs e) { base.OnInit(e); ClassMetadata cm = new ClassMetadata(); cm.Fields = MultiStepWizards.PlaceAnOrder.EditOrderLineItemProductDemographics; // setup the metadata CustomFieldSet1.Metadata = cm; DataEntryViewMetadata vm = new DataEntryViewMetadata(); vm.Sections = new List <MemberSuite.SDK.Manifests.Command.ViewMetadata.ControlSection>(); ViewMetadata.ControlSection cs = new ViewMetadata.ControlSection(); foreach (var f in cm.Fields) { ControlMetadata cm2 = ControlMetadata.FromFieldMetadata(f); cm2.IsRequired = null; // important, we don't want this overrideen cs.LeftControls.Add(cm2); } vm.Sections.Add(cs); CustomFieldSet1.PageLayout = vm; CustomFieldSet1.Render(); }
private void _renderControls(ViewMetadata.ControlSection section, PlaceHolder container) { if (section.LeftControls == null) { section.LeftControls = new List <ControlMetadata>(); } if (section.RightControls == null) { section.RightControls = new List <ControlMetadata>(); } var leftControls = new List <ControlMetadata>(section.LeftControls); var rightControls = new List <ControlMetadata>(section.RightControls); // now, let's remove all disabled controls, b/c they probably have a portal accessibility restriction // MS-4675 leftControls.RemoveAll(x => !x.Enabled); rightControls.RemoveAll(x => !x.Enabled); int maxRows = leftControls.Count > rightControls.Count ? leftControls.Count : rightControls.Count; var ht = new HtmlTable(); if (maxRows > 0) { container.Controls.Add(ht); } for (int i = 0; i <= maxRows; i++) { HtmlTableRow tableRow = new HtmlTableRow(); ht.Rows.Add(tableRow); //HtmlTableCell tcLeftLabel = new HtmlTableCell(); //tableRow.Cells.Add(tcLeftLabel); //HtmlTableCell tcLeftControl = new HtmlTableCell(); //tableRow.Cells.Add(tcLeftControl); // first, render the left side if (leftControls.Count > i) { renderControl(tableRow, leftControls[i]); } if (rightControls.Count > i) { renderControl(tableRow, rightControls[i]); } //return new ControlGroupInstructions(manager.RowSpan - 1, createNewRow); } }
protected DataEntryViewMetadata createViewMetadataFromEntryQuestions() { var result = new DataEntryViewMetadata(); var baseSection = new ViewMetadata.ControlSection(); baseSection.SubSections = new List <ViewMetadata.ControlSection>(); var currentSection = new ViewMetadata.ControlSection(); currentSection.LeftControls = new List <ControlMetadata>(); baseSection.SubSections.Add(currentSection); foreach (var question in targetCompetitionQuestions) { var field = new ControlMetadata { DataSourceExpression = question.Name }; // This isn't necessary - the field is aqequately described already ////ControlMetadata field = ControlMetadata.FromFieldMetadata(question.FieldDefinition); if (field.DisplayType == FieldDisplayType.Separator) { if (currentSection.LeftControls != null && currentSection.LeftControls.Count > 0) // we have to create a new section { currentSection = new ViewMetadata.ControlSection(); currentSection.LeftControls = new List <ControlMetadata>(); baseSection.SubSections.Add(currentSection); } currentSection.Name = Guid.NewGuid().ToString(); currentSection.Label = field.PortalPrompt ?? field.Label; // set the section label continue; } currentSection.LeftControls.Add(field); } result.Sections = new List <ViewMetadata.ControlSection> { baseSection }; return(result); }
private void _renderSection(ViewMetadata.ControlSection section) { if (section.Label != null && section.Label.Trim() != "") { // add the section header var header = new HtmlGenericControl("h2"); header.InnerText = section.Label; phCustomFields.Controls.Add(header); } // render text if (!string.IsNullOrWhiteSpace(section.Text)) { phCustomFields.Controls.Add(new LiteralControl(section.Text)); } // now, render controls _renderControls(section, phCustomFields); }
protected DataEntryViewMetadata createViewMetadataFromEntryQuestions() { var result = new DataEntryViewMetadata(); var baseSection = new ViewMetadata.ControlSection(); baseSection.SubSections = new List <ViewMetadata.ControlSection>(); var currentSection = new ViewMetadata.ControlSection(); currentSection.LeftControls = new List <ControlMetadata>(); baseSection.SubSections.Add(currentSection); foreach (var question in targetCompetitionQuestions.OrderBy(o => o.DisplayOrder)) { var field = ControlMetadata.FromFieldMetadata(question.FieldDefinition); if (field.DisplayType == FieldDisplayType.Separator) { if (currentSection.LeftControls != null && currentSection.LeftControls.Count > 0) // we have to create a new section { currentSection = new ViewMetadata.ControlSection(); currentSection.LeftControls = new List <ControlMetadata>(); baseSection.SubSections.Add(currentSection); } currentSection.Name = Guid.NewGuid().ToString(); currentSection.Label = field.PortalPrompt ?? field.Label; // set the section label continue; } if (currentSection.LeftControls != null) { currentSection.LeftControls.Add(field); } } result.Sections = new List <ViewMetadata.ControlSection> { baseSection }; return(result); }
protected DataEntryViewMetadata createViewMetadataFromRegistrationFields() { DataEntryViewMetadata result = new DataEntryViewMetadata(); ViewMetadata.ControlSection baseSection = null; result.Sections = new List <ViewMetadata.ControlSection> (); foreach (var field in targetRegistrationFields) { if (field.DisplayType == FieldDisplayType.Separator || baseSection == null) { // create a new section baseSection = new ViewMetadata.ControlSection { Label = field.Label, SubSections = new List <ViewMetadata.ControlSection>() }; result.Sections.Add(baseSection); continue; } //MS-1358 field.IsRequired = field.IsRequiredInPortal; //MS-1359 if (field.DisplayType == FieldDisplayType.LargeTextBox) { field.UseEntireRow = true; } baseSection.LeftControls.Add(field); } // remove empty sections result.Sections.RemoveAll(x => x.LeftControls == null || x.LeftControls.Count == 0); return(result); }
protected DataEntryViewMetadata createViewMetadataFromRegistrationFields() { DataEntryViewMetadata result = new DataEntryViewMetadata(); ViewMetadata.ControlSection baseSection = new ViewMetadata.ControlSection(); baseSection.SubSections = new List <ViewMetadata.ControlSection>(); var currentSection = new ViewMetadata.ControlSection(); currentSection.LeftControls = new List <ControlMetadata>(); baseSection.SubSections.Add(currentSection); foreach (var field in targetRegistrationFields) { if (field.DisplayType == FieldDisplayType.Separator) { if (currentSection.LeftControls != null && currentSection.LeftControls.Count > 0) // we have to create a new section { currentSection = new ViewMetadata.ControlSection(); currentSection.LeftControls = new List <ControlMetadata>(); baseSection.SubSections.Add(currentSection); } currentSection.Name = Guid.NewGuid().ToString(); currentSection.Label = field.PortalPrompt ?? field.Label; // set the section label continue; } currentSection.LeftControls.Add(field); } result.Sections = new List <ViewMetadata.ControlSection> { baseSection }; return(result); }
protected DataEntryViewMetadata createViewMetadata(List <FieldMetadata> fields, bool isForSearch) { DataEntryViewMetadata result = new DataEntryViewMetadata(); ViewMetadata.ControlSection baseSection = new ViewMetadata.ControlSection(); baseSection.SubSections = new List <ViewMetadata.ControlSection>(); var currentSection = new ViewMetadata.ControlSection(); currentSection.LeftControls = new List <ControlMetadata>(); baseSection.SubSections.Add(currentSection); foreach (var field in fields) { if (field.DisplayType == FieldDisplayType.Separator) { if (currentSection.LeftControls != null && currentSection.LeftControls.Count > 0) // we have to create a new section { currentSection = new ViewMetadata.ControlSection(); currentSection.LeftControls = new List <ControlMetadata>(); baseSection.SubSections.Add(currentSection); } currentSection.Name = Guid.NewGuid().ToString(); currentSection.Label = field.PortalPrompt ?? field.Label; // set the section label continue; } // // MS-1251 - REQUIREMENT to have to/from fields for numeric fields var control = ControlMetadata.FromFieldMetadata(field); if (isForSearch) { control.PortalPrompt = null; } switch (control.DataType) { case FieldDataType.Integer: case FieldDataType.Decimal: case FieldDataType.Date: case FieldDataType.DateTime: // we need to use a range var controlTo = control.Clone(); control.Label += " - Range Start"; control.Name += "__from"; control.DataSourceExpression += "__from"; currentSection.LeftControls.Add(control); controlTo.Label += " - Range End"; controlTo.Name += "__to"; controlTo.DataSourceExpression += "__to"; currentSection.LeftControls.Add(controlTo); break; default: currentSection.LeftControls.Add(control); break; } } result.Sections = new List <ViewMetadata.ControlSection> { baseSection }; return(result); }