private void RenderClickWrapperBeginTag(BocColumnRenderingContext <BocCustomColumnDefinition> renderingContext)
        {
            string onClick = renderingContext.Control.HasClientScript ? c_onCommandClickScript : string.Empty;

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onClick);
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Span);
        }
        public override void SetUp()
        {
            Column            = new BocCustomColumnDefinition();
            Column.CustomCell = new StubCustomCellDefinition();

            base.SetUp();

            IBusinessObject firstObject  = (IBusinessObject)((TypeWithReference)BusinessObject).FirstValue;
            IBusinessObject secondObject = (IBusinessObject)((TypeWithReference)BusinessObject).SecondValue;
            var             triplets     = new[]
            {
                new BocListCustomColumnTuple(firstObject, 10, new WebControl(HtmlTextWriterTag.Div)),
                new BocListCustomColumnTuple(secondObject, 20, new HtmlGenericControl("div"))
            };
            var customColumns =
                new ReadOnlyDictionary <BocCustomColumnDefinition, BocListCustomColumnTuple[]> (
                    new Dictionary <BocCustomColumnDefinition, BocListCustomColumnTuple[]>
            {
                { Column, triplets }
            });

            List.Stub(mock => mock.CustomColumns).Return(customColumns);

            _bocListQuirksModeCssClassDefinition = new BocListQuirksModeCssClassDefinition();

            _renderingContext = new BocColumnRenderingContext <BocCustomColumnDefinition> (new BocColumnRenderingContext(HttpContext, Html.Writer, List, Column, 0, 0));
        }
        private void RenderEditedRowCellContents(
            BocColumnRenderingContext <BocRowEditModeColumnDefinition> renderingContext,
            int originalRowIndex,
            IBusinessObject businessObject)
        {
            RenderCommandControl(
                renderingContext,
                originalRowIndex,
                businessObject,
                BocList.RowEditModeCommand.Save,
                BocList.ResourceIdentifier.RowEditModeSaveAlternateText,
                renderingContext.ColumnDefinition.SaveIcon,
                renderingContext.ColumnDefinition.SaveText);

            renderingContext.Writer.Write(" ");

            RenderCommandControl(
                renderingContext,
                originalRowIndex,
                businessObject,
                BocList.RowEditModeCommand.Cancel,
                BocList.ResourceIdentifier.RowEditModeCancelAlternateText,
                renderingContext.ColumnDefinition.CancelIcon,
                renderingContext.ColumnDefinition.CancelText);
        }
        /// <summary>
        /// Renders the cell contents depending on the <paramref name="dataRowRenderEventArgs"/>'s
        /// <see cref="BocListDataRowRenderEventArgs.IsEditableRow"/> property.
        /// <seealso cref="BocColumnRendererBase{TBocColumnDefinition}.RenderCellContents"/>
        /// </summary>
        /// <remarks>
        /// If the current row is being edited, "Save" and "Cancel" controls are rendered; if the row can be edited, an "Edit" control is rendered;
        /// if the row cannot be edited, an empty cell is rendered.
        /// Since the "Save", "Cancel" and "Edit" controls are structurally identical, their actual rendering is done by <see cref="RenderCommandControl"/>
        /// </remarks>
        protected override void RenderCellContents(
            BocColumnRenderingContext <BocRowEditModeColumnDefinition> renderingContext,
            BocListDataRowRenderEventArgs dataRowRenderEventArgs,
            int rowIndex,
            bool showIcon)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);
            ArgumentUtility.CheckNotNull("dataRowRenderEventArgs", dataRowRenderEventArgs);

            bool isEditableRow    = dataRowRenderEventArgs.IsEditableRow;
            int  originalRowIndex = dataRowRenderEventArgs.ListIndex;
            var  businessObject   = dataRowRenderEventArgs.BusinessObject;
            bool isEditedRow      = renderingContext.Control.EditModeController.GetEditableRow(originalRowIndex) != null;

            if (isEditedRow)
            {
                RenderEditedRowCellContents(renderingContext, originalRowIndex, businessObject);
            }
            else if (isEditableRow)
            {
                RenderEditableRowCellContents(renderingContext, originalRowIndex, businessObject);
            }
            else
            {
                renderingContext.Writer.Write(c_whiteSpace);
            }
        }
 public virtual void RenderDataColumnDeclaration(
     BocColumnRenderingContext <TBocColumnDefinition> renderingContext, bool isTextXml)
 {
     renderingContext.Writer.WriteBeginTag("col");
     if (!renderingContext.ColumnDefinition.Width.IsEmpty)
     {
         renderingContext.Writer.Write(" style=\"");
         string width;
         var    columnAsValueColumn = renderingContext.ColumnDefinition as BocValueColumnDefinition;
         if (columnAsValueColumn != null && columnAsValueColumn.EnforceWidth && renderingContext.ColumnDefinition.Width.Type != UnitType.Percentage)
         {
             width = "2em";
         }
         else
         {
             width = renderingContext.ColumnDefinition.Width.ToString();
         }
         renderingContext.Writer.WriteStyleAttribute("width", width);
         renderingContext.Writer.Write("\"");
     }
     if (isTextXml)
     {
         renderingContext.Writer.Write(" />");
     }
     else
     {
         renderingContext.Writer.Write(">");
     }
 }
        public virtual void RenderTitleCell(
            BocColumnRenderingContext <TBocColumnDefinition> renderingContext, SortingDirection sortingDirection, int orderIndex)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);

            string cssClassTitleCell = CssClasses.TitleCell;

            if (!string.IsNullOrEmpty(renderingContext.ColumnDefinition.CssClass))
            {
                cssClassTitleCell += " " + renderingContext.ColumnDefinition.CssClass;
            }
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClassTitleCell);
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Th);

            RenderTitleCellMarkers(renderingContext);
            RenderBeginTagTitleCellSortCommand(renderingContext);
            RenderTitleCellText(renderingContext);
            if (renderingContext.Control.IsClientSideSortingEnabled || renderingContext.Control.HasSortingKeys)
            {
                RenderTitleCellSortingButton(renderingContext, sortingDirection, orderIndex);
            }
            RenderEndTagTitleCellSortCommand(renderingContext.Writer);

            renderingContext.Writer.RenderEndTag();
        }
        private string GetImageUrl(BocColumnRenderingContext <TBocColumnDefinition> renderingContext, SortingDirection sortingDirection)
        {
            string imageUrl = string.Empty;

            //  Button Asc -> Button Desc -> No Button
            switch (sortingDirection)
            {
            case SortingDirection.Ascending:
            {
                imageUrl = ResourceUrlFactory.CreateResourceUrl(
                    typeof(BocColumnQuirksModeRendererBase <>),
                    ResourceType.Image,
                    c_sortAscendingIcon).GetUrl();
                break;
            }

            case SortingDirection.Descending:
            {
                imageUrl = ResourceUrlFactory.CreateResourceUrl(
                    typeof(BocColumnQuirksModeRendererBase <>),
                    ResourceType.Image,
                    c_sortDescendingIcon).GetUrl();
                break;
            }

            case SortingDirection.None:
            {
                break;
            }
            }
            return(imageUrl);
        }
 /// <summary>
 /// Renders the end tag to the crop span element if a begin tag has been rendered.
 /// </summary>
 /// <param name="renderingContext">The <see cref="BocColumnRenderingContext{BocColumnDefinition}"/>.</param>
 /// <param name="enforceWidth">Specifies if a corresponding begin tag has been rendered.</param>
 private void RenderCropSpanEndTag(BocColumnRenderingContext <TBocColumnDefinition> renderingContext, bool enforceWidth)
 {
     if (enforceWidth)
     {
         renderingContext.Writer.RenderEndTag();
     }
 }
        private void RenderBeginTagTitleCellSortCommand(BocColumnRenderingContext <TBocColumnDefinition> renderingContext)
        {
            bool hasSortingCommand = renderingContext.Control.IsClientSideSortingEnabled
                                     &&
                                     (renderingContext.ColumnDefinition is IBocSortableColumnDefinition &&
                                      ((IBocSortableColumnDefinition)renderingContext.ColumnDefinition).IsSortable);

            if (hasSortingCommand)
            {
                if (!renderingContext.Control.EditModeController.IsRowEditModeActive && !renderingContext.Control.EditModeController.IsListEditModeActive &&
                    renderingContext.Control.HasClientScript)
                {
                    var sortCommandID = renderingContext.Control.ClientID + "_" + renderingContext.ColumnIndex + "_SortCommand";
                    renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Id, sortCommandID);

                    string argument      = BocList.SortCommandPrefix + renderingContext.ColumnIndex;
                    string postBackEvent = renderingContext.Control.Page.ClientScript.GetPostBackEventReference(renderingContext.Control, argument);
                    postBackEvent += "; return false;";
                    renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Onclick, postBackEvent);

                    renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Href, "#");

                    renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.A);
                }
                else
                {
                    renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Span);
                }
            }
            else
            {
                renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Span);
            }
        }
        protected bool RenderBeginTagDataCellCommand(
            BocColumnRenderingContext <TBocColumnDefinition> renderingContext, IBusinessObject businessObject, int originalRowIndex)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);
            ArgumentUtility.CheckNotNull("businessObject", businessObject);

            BocListItemCommand command = renderingContext.ColumnDefinition.Command;

            if (command == null)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(command.ItemID))
            {
                command.ItemID = "Column_" + renderingContext.ColumnIndex + "_Command";
            }

            bool isReadOnly = renderingContext.Control.IsReadOnly;
            bool isActive   = command.Show == CommandShow.Always ||
                              isReadOnly && command.Show == CommandShow.ReadOnly ||
                              !isReadOnly && command.Show == CommandShow.EditMode;

            bool isCommandAllowed = (command.Type != CommandType.None) && !renderingContext.Control.EditModeController.IsRowEditModeActive;
            bool isCommandEnabled = (command.CommandState == null) ||
                                    command.CommandState.IsEnabled(renderingContext.Control, businessObject, renderingContext.ColumnDefinition);
            bool isCommandWaiCompliant = (!WcagHelper.Instance.IsWaiConformanceLevelARequired() || command.Type == CommandType.Href);

            if (isActive && isCommandAllowed && isCommandEnabled && isCommandWaiCompliant)
            {
                string objectID = null;
                IBusinessObjectWithIdentity businessObjectWithIdentity = businessObject as IBusinessObjectWithIdentity;
                if (businessObjectWithIdentity != null)
                {
                    objectID = businessObjectWithIdentity.UniqueIdentifier;
                }

                string argument =
                    renderingContext.Control.GetListItemCommandArgument(renderingContext.ColumnIndex, new BocListRow(originalRowIndex, businessObject));
                string postBackEvent = renderingContext.Control.Page.ClientScript.GetPostBackEventReference(renderingContext.Control, argument) + ";";
                string onClick       = renderingContext.Control.HasClientScript ? c_onCommandClickScript : string.Empty;
                if (command.Type == CommandType.None)
                {
                    renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClasses.Disabled);
                }

                var commandIDBackup = command.ItemID;
                try
                {
                    command.ItemID = command.ItemID + "_Row_" + originalRowIndex;
                    command.RenderBegin(renderingContext.Writer, LegacyRenderingFeatures.ForLegacy, postBackEvent, onClick, originalRowIndex, objectID, businessObject as ISecurableObject);
                }
                finally
                {
                    command.ItemID = commandIDBackup;
                }
                return(true);
            }
            return(false);
        }
        private void RenderCustomCellInnerControls(BocColumnRenderingContext <BocCustomColumnDefinition> renderingContext, int originalRowIndex, int rowIndex)
        {
            BocListCustomColumnTuple[] customColumnTuples = renderingContext.Control.CustomColumns[renderingContext.ColumnDefinition];
            BocListCustomColumnTuple   customColumnTuple;

            if (customColumnTuples.Length > rowIndex && customColumnTuples[rowIndex].Item2 == originalRowIndex)
            {
                customColumnTuple = customColumnTuples[rowIndex];
            }
            else
            {
                customColumnTuple = customColumnTuples.FirstOrDefault(t => t.Item2 == originalRowIndex);
            }

            if (customColumnTuple == null)
            {
                renderingContext.Writer.Write(c_whiteSpace);
                return;
            }

            RenderClickWrapperBeginTag(renderingContext);

            Control control = customColumnTuple.Item3;

            if (control != null)
            {
                ApplyStyleDefaults(control);
                control.RenderControl(renderingContext.Writer);
            }

            RenderClickWrapperEndTag(renderingContext);
        }
        /// <summary>
        /// Renders a <see cref="DropDownMenu"/> with the options for the current row.
        /// <seealso cref="BocColumnRendererBase{TBocColumnDefinition}.RenderCellContents"/>
        /// </summary>
        /// <remarks>
        /// The menu title is generated from the <see cref="DropDownMenu.TitleText"/> and <see cref="DropDownMenu.TitleText"/> properties of
        /// the column definition in <see cref="BocColumnRenderingContext.ColumnDefinition"/>, and populated with the menu items in
        /// the <see cref="IBocList.RowMenus"/> property of <see cref="IBocList"/>.
        /// </remarks>
        protected override void RenderCellContents(
            BocColumnRenderingContext <BocDropDownMenuColumnDefinition> renderingContext,
            BocListDataRowRenderEventArgs dataRowRenderEventArgs,
            int rowIndex,
            bool showIcon)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);
            ArgumentUtility.CheckNotNull("dataRowRenderEventArgs", dataRowRenderEventArgs);

            if (renderingContext.Control.RowMenus.Count <= rowIndex)
            {
                renderingContext.Writer.Write(c_whiteSpace);
                return;
            }

            var dropDownMenu = renderingContext.Control.RowMenus[rowIndex];

            if (renderingContext.Control.HasClientScript)
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Onclick, c_onCommandClickScript);
            }
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Div); // Begin div

            dropDownMenu.Enabled = !renderingContext.Control.EditModeController.IsRowEditModeActive;

            dropDownMenu.TitleText = renderingContext.ColumnDefinition.MenuTitleText;
            dropDownMenu.TitleIcon = renderingContext.ColumnDefinition.MenuTitleIcon;
            dropDownMenu.RenderControl(renderingContext.Writer);

            renderingContext.Writer.RenderEndTag(); // End div
        }
Ejemplo n.º 13
0
 protected override void RenderCellContents(
     BocColumnRenderingContext <StubColumnDefinition> renderingContext,
     BocListDataRowRenderEventArgs dataRowRenderEventArgs,
     int rowIndex,
     bool showIcon)
 {
     throw new NotImplementedException();
 }
        private void RenderCustomCellDirectly(
            BocColumnRenderingContext <BocCustomColumnDefinition> renderingContext, IBusinessObject businessObject, int columnIndex, int originalRowIndex)
        {
            string onClick = renderingContext.Control.HasClientScript ? c_onCommandClickScript : string.Empty;
            BocCustomCellRenderArguments arguments = new BocCustomCellRenderArguments(
                renderingContext.Control, businessObject, renderingContext.ColumnDefinition, columnIndex, originalRowIndex, onClick);

            renderingContext.ColumnDefinition.CustomCell.RenderInternal(renderingContext.Writer, arguments);
        }
Ejemplo n.º 15
0
 protected override void RenderDataCell(
     BocColumnRenderingContext <StubColumnDefinition> renderingContext,
     int rowIndex,
     bool showIcon,
     BocListDataRowRenderEventArgs dataRowRenderEventArgs)
 {
     renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Td);
     renderingContext.Writer.RenderEndTag();
 }
 public void SetUp()
 {
     _nullColumnRenderer = new NullColumnRenderer();
     _columnDefinition   = new StubColumnDefinition();
     _htmlTextWriterMock = MockRepository.GenerateStrictMock <HtmlTextWriter> ();
     _httpContextStub    = MockRepository.GenerateStub <HttpContextBase> ();
     _bocListStub        = MockRepository.GenerateStub <IBocList> ();
     _renderingContext   = new BocColumnRenderingContext <StubColumnDefinition> (
         new BocColumnRenderingContext(_httpContextStub, _htmlTextWriterMock, _bocListStub, _columnDefinition, 0, 0));
 }
 private void RenderEndTag(BocColumnRenderingContext <TBocColumnDefinition> renderingContext, bool isCommandEnabled)
 {
     if (isCommandEnabled)
     {
         RenderEndTagDataCellCommand(renderingContext);
     }
     else
     {
         renderingContext.Writer.RenderEndTag();
     }
 }
 private void RenderTitleCellText(BocColumnRenderingContext <TBocColumnDefinition> renderingContext)
 {
     if (renderingContext.Control.IsDesignMode && string.IsNullOrEmpty(renderingContext.ColumnDefinition.ColumnTitleDisplayValue))
     {
         renderingContext.Writer.Write(c_designModeEmptyContents);
     }
     else
     {
         string contents = StringUtility.EmptyToNull(renderingContext.ColumnDefinition.ColumnTitleDisplayValue) ?? c_whiteSpace;
         renderingContext.Writer.Write(contents);
     }
 }
 void IBocColumnRenderer.RenderDataCell(
     BocColumnRenderingContext renderingContext,
     int rowIndex,
     bool showIcon,
     BocListDataRowRenderEventArgs dataRowRenderEventArgs)
 {
     RenderDataCell(
         new BocColumnRenderingContext <TBocColumnDefinition>(renderingContext),
         rowIndex,
         showIcon,
         dataRowRenderEventArgs);
 }
        protected void RenderCellIcon(BocColumnRenderingContext <TBocColumnDefinition> renderingContext, IBusinessObject businessObject)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);
            ArgumentUtility.CheckNotNull("businessObject", businessObject);

            IconInfo icon = BusinessObjectBoundWebControl.GetIcon(businessObject, businessObject.BusinessObjectClass.BusinessObjectProvider);

            if (icon != null)
            {
                icon.Render(renderingContext.Writer, renderingContext.Control);
                renderingContext.Writer.Write(c_whiteSpace);
            }
        }
 private void RenderEditableRowCellContents(
     BocColumnRenderingContext <BocRowEditModeColumnDefinition> renderingContext,
     int originalRowIndex,
     IBusinessObject businessObject)
 {
     RenderCommandControl(
         renderingContext,
         originalRowIndex,
         businessObject,
         BocList.RowEditModeCommand.Edit,
         BocList.ResourceIdentifier.RowEditModeEditAlternateText,
         renderingContext.ColumnDefinition.EditIcon,
         renderingContext.ColumnDefinition.EditText);
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Renders a string representation of the property of <paramref name="businessObject"/> that is shown in the column.
        /// </summary>
        /// <param name="renderingContext">The <see cref="BocColumnRenderingContext{BocColumnDefinition}"/>.</param>
        /// <param name="businessObject">The <see cref="IBusinessObject"/> whose property will be rendered.</param>
        /// <param name="showEditModeControl">Prevents rendering if <see langword="true"/>.</param>
        /// <param name="editableRow">Ignored.</param>
        protected override void RenderCellText(BocColumnRenderingContext <BocCompoundColumnDefinition> renderingContext, IBusinessObject businessObject, bool showEditModeControl, IEditableRow editableRow)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);
            ArgumentUtility.CheckNotNull("businessObject", businessObject);

            string valueColumnText = null;

            if (!showEditModeControl)
            {
                valueColumnText = renderingContext.ColumnDefinition.GetStringValue(businessObject);
            }

            RenderValueColumnCellText(renderingContext, valueColumnText);
        }
        /// <summary>
        /// Renders a command control as link with an icon, a text or both.
        /// </summary>
        /// <param name="renderingContext">The <see cref="BocColumnRenderingContext{BocColumnDefinition}"/>.</param>
        /// <param name="originalRowIndex">The zero-based index of the current row in <see cref="IBocList"/></param>
        /// <param name="businessObject">The <see cref="IBusinessObject"/> associated with the current row.</param>
        /// <param name="command">The <see cref="Remotion.ObjectBinding.Web.UI.Controls.BocList.RowEditModeCommand"/> that is issued
        /// when the control is clicked. Must not be <see langword="null" />.</param>
        /// <param name="alternateText">The <see cref="Remotion.ObjectBinding.Web.UI.Controls.BocList.ResourceIdentifier"/>
        /// specifying which resource to load as alternate text to the icon.</param>
        /// <param name="icon">The icon to render; must not be <see langword="null"/>.
        /// To skip the icon, set <see cref="IconInfo.Url"/> to <see langword="null" />.</param>
        /// <param name="text">The text to render after the icon. May be <see langword="null"/>, in which case no text is rendered.</param>
        protected virtual void RenderCommandControl(
            BocColumnRenderingContext <BocRowEditModeColumnDefinition> renderingContext,
            int originalRowIndex,
            IBusinessObject businessObject,
            BocList.RowEditModeCommand command,
            BocList.ResourceIdentifier alternateText,
            IconInfo icon,
            string text)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);
            ArgumentUtility.CheckNotNull("businessObject", businessObject);
            ArgumentUtility.CheckNotNull("icon", icon);

            if (!renderingContext.Control.IsReadOnly && renderingContext.Control.HasClientScript)
            {
                string argument      = renderingContext.Control.GetRowEditCommandArgument(new BocListRow(originalRowIndex, businessObject), command);
                string postBackEvent = renderingContext.Control.Page.ClientScript.GetPostBackEventReference(renderingContext.Control, argument) + ";";
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Href, "#");
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Onclick, postBackEvent + c_onCommandClickScript);
            }
            var commandID = renderingContext.Control.ClientID + "_Column_" + renderingContext.ColumnIndex + "_RowEditCommand_" + command + "_Row_" + originalRowIndex;

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Id, commandID);
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.A);

            bool hasIcon = icon.HasRenderingInformation;
            bool hasText = !string.IsNullOrEmpty(text);

            if (hasIcon && hasText)
            {
                icon.Render(renderingContext.Writer, renderingContext.Control);
                renderingContext.Writer.Write(c_whiteSpace);
            }
            else if (hasIcon)
            {
                bool hasAlternateText = !string.IsNullOrEmpty(icon.AlternateText);
                if (!hasAlternateText)
                {
                    icon.AlternateText = renderingContext.Control.GetResourceManager().GetString(alternateText);
                }

                icon.Render(renderingContext.Writer, renderingContext.Control);
            }
            if (hasText)
            {
                renderingContext.Writer.Write(text); // Do not HTML encode.
            }
            renderingContext.Writer.RenderEndTag();
        }
        private bool RenderBeginTag(
            BocColumnRenderingContext <TBocColumnDefinition> renderingContext, int originalRowIndex, IBusinessObject businessObject, string valueColumnText)
        {
            bool isCommandEnabled = false;

            if (!string.IsNullOrEmpty(valueColumnText))
            {
                isCommandEnabled = RenderBeginTagDataCellCommand(renderingContext, businessObject, originalRowIndex);
            }
            if (!isCommandEnabled)
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClasses.Content);
                renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Span);
            }
            return(isCommandEnabled);
        }
        public override void SetUp()
        {
            Column         = new BocCommandColumnDefinition();
            Column.Command = new BocListItemCommand(CommandType.Event);
            Column.Command.EventCommand = new Command.EventCommandInfo();
            Column.Command.EventCommand.RequiresSynchronousPostBack = true;
            Column.Text         = "TestCommand";
            Column.ColumnTitle  = "FirstColumn";
            Column.OwnerControl = List;

            base.SetUp();

            _bocListQuirksModeCssClassDefinition = new BocListQuirksModeCssClassDefinition();
            _renderingContext =
                new BocColumnRenderingContext <BocCommandColumnDefinition> (new BocColumnRenderingContext(HttpContext, Html.Writer, List, Column, 0, 0));
        }
Ejemplo n.º 26
0
        private void RenderEditModeControl(
            BocColumnRenderingContext <BocSimpleColumnDefinition> renderingContext, IBusinessObject businessObject, IEditableRow editableRow)
        {
            if (renderingContext.Control.HasClientScript)
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Onclick, c_onCommandClickScript);
            }
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Span); // Begin span

            editableRow.RenderSimpleColumnCellEditModeControl(
                renderingContext.Writer,
                renderingContext.ColumnDefinition,
                businessObject,
                renderingContext.ColumnIndex);

            renderingContext.Writer.RenderEndTag(); // End span
        }
        public void TestDiagnosticMetadataRendering()
        {
            IBocColumnRenderer renderer = new BocSimpleColumnRenderer(
                new FakeResourceUrlFactory(),
                RenderingFeatures.WithDiagnosticMetadata,
                _bocListCssClassDefinition);

            _renderingContext =
                new BocColumnRenderingContext <BocSimpleColumnDefinition> (new BocColumnRenderingContext(HttpContext, Html.Writer, List, Column, 0, 6));

            renderer.RenderDataCell(_renderingContext, 0, false, EventArgs);

            var document = Html.GetResultDocument();
            var td       = Html.GetAssertedChildElement(document, "td", 0);

            Html.AssertAttribute(td, DiagnosticMetadataAttributesForObjectBinding.BocListCellIndex, 7.ToString());
        }
Ejemplo n.º 28
0
        public override void SetUp()
        {
            Column              = new BocCompoundColumnDefinition();
            Column.ColumnTitle  = "TestColumn1";
            Column.ColumnTitle  = "FirstColumn";
            Column.Command      = null;
            Column.EnforceWidth = false;
            Column.FormatString = "{0}";

            base.SetUp();

            Column.PropertyPathBindings.Add(new PropertyPathBinding("DisplayName"));

            _bocListQuirksModeCssClassDefinition = new BocListQuirksModeCssClassDefinition();

            _renderingContext =
                new BocColumnRenderingContext <BocCompoundColumnDefinition> (new BocColumnRenderingContext(HttpContext, Html.Writer, List, Column, 0, 0));
        }
        public override void SetUp()
        {
            Column                        = new BocSimpleColumnDefinition();
            Column.Command                = null;
            Column.IsDynamic              = false;
            Column.IsReadOnly             = false;
            Column.ColumnTitle            = "FirstColumn";
            Column.PropertyPathIdentifier = "DisplayName";
            Column.FormatString           = "unusedWithReferenceValue";
            Column.OwnerControl           = List;

            base.SetUp();

            _bocListCssClassDefinition = new BocListCssClassDefinition();

            _renderingContext =
                new BocColumnRenderingContext <BocSimpleColumnDefinition> (new BocColumnRenderingContext(HttpContext, Html.Writer, List, Column, 0, 0));
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Renders either the string value of the <paramref name="businessObject"/> or the edit mode controls,
        /// depending on <paramref name="showEditModeControl"/>
        /// </summary>
        /// <param name="renderingContext">The <see cref="BocColumnRenderingContext{BocColumnDefinition}"/>. </param>
        /// <param name="businessObject">The <see cref="IBusinessObject"/> for the current row.</param>
        /// <param name="showEditModeControl">Specifies if the edit controls will be rendered (<see langword="true"/>) or
        /// a string representation of <paramref name="businessObject"/> will be displayed (<see langword="false"/>).</param>
        /// <param name="editableRow">The <see cref="EditableRow"/> object used to actually render the edit row controls.
        /// May be <see langword="null"/> if <paramref name="showEditModeControl"/> is <see langword="false"/>.</param>
        protected override void RenderCellText(
            BocColumnRenderingContext <BocSimpleColumnDefinition> renderingContext,
            IBusinessObject businessObject,
            bool showEditModeControl,
            IEditableRow editableRow)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);
            ArgumentUtility.CheckNotNull("businessObject", businessObject);

            if (showEditModeControl)
            {
                RenderEditModeControl(renderingContext, businessObject, editableRow);
            }
            else
            {
                RenderValueColumnCellText(renderingContext, renderingContext.ColumnDefinition.GetStringValue(businessObject));
            }
        }