Ejemplo n.º 1
0
        private string GetCssClassTableRow(
            BocListRenderingContext renderingContext,
            bool isChecked,
            BocListDataRowRenderEventArgs dataRowRenderEventArgs)
        {
            string cssClassTableRow = CssClasses.DataRow;

            if (dataRowRenderEventArgs.IsOddRow)
            {
                cssClassTableRow += " " + CssClasses.DataRowOdd;
            }
            else
            {
                cssClassTableRow += " " + CssClasses.DataRowEven;
            }

            if (!string.IsNullOrEmpty(dataRowRenderEventArgs.AdditionalCssClassForDataRow))
            {
                cssClassTableRow += " " + dataRowRenderEventArgs.AdditionalCssClassForDataRow;
            }

            if (isChecked && renderingContext.Control.AreDataRowsClickSensitive())
            {
                cssClassTableRow += " " + CssClasses.DataRowSelected;
            }

            return(cssClassTableRow);
        }
        /// <summary> Renders the zero-based row index normalized to a one-based format
        /// (Optionally as a label for the selector control). </summary>
        private void RenderRowIndex(BocListRenderingContext renderingContext, int index, string selectorControlID)
        {
            bool hasSelectorControl = selectorControlID != null;

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClasses.Content);
            if (hasSelectorControl)
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.For, selectorControlID);
                if (renderingContext.Control.HasClientScript)
                {
                    const string script = "BocList_OnSelectorControlLabelClick();";
                    renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Onclick, script);
                }
                renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Label);
            }
            else
            {
                renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Span);
            }
            int renderedIndex = index + 1;

            if (renderingContext.Control.IndexOffset != null)
            {
                renderedIndex += renderingContext.Control.IndexOffset.Value;
            }
            renderingContext.Writer.Write(renderedIndex);
            renderingContext.Writer.RenderEndTag();
        }
Ejemplo n.º 3
0
 private void RenderDataCells(BocListRenderingContext renderingContext, int rowIndex, BocListDataRowRenderEventArgs dataRowRenderEventArgs)
 {
     foreach (BocColumnRenderer columnRenderer in renderingContext.ColumnRenderers)
     {
         columnRenderer.RenderDataCell(renderingContext, rowIndex, dataRowRenderEventArgs);
     }
 }
        private void RenderNavigationIcon(BocListRenderingContext renderingContext, bool isInactive, GoToOption command, int pageIndex)
        {
            var navigateCommandID = renderingContext.Control.ClientID + "_Navigation_" + command;

            if (isInactive)
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Id, navigateCommandID);
                renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.A);

                var imageUrl = GetResolvedImageUrl(s_inactiveIcons[command]);
                new IconInfo(imageUrl.GetUrl()).Render(renderingContext.Writer, renderingContext.Control);

                renderingContext.Writer.RenderEndTag();
            }
            else
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Id, navigateCommandID);

                var currentPageControlClientID = GetCurrentPageIndexControlID(renderingContext);
                var postBackEvent = string.Format("$('#{0}').val({1}).trigger('change');", currentPageControlClientID, pageIndex);
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Onclick, postBackEvent);

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

                renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.A);

                var imageUrl = GetResolvedImageUrl(s_activeIcons[command]);
                var icon     = new IconInfo(imageUrl.GetUrl());
                icon.AlternateText = GetResourceManager(renderingContext).GetString(s_alternateTexts[command]);
                icon.Render(renderingContext.Writer, renderingContext.Control);

                renderingContext.Writer.RenderEndTag();
            }
        }
Ejemplo n.º 5
0
        private void RenderTitleRowSelectorControl(BocListRenderingContext renderingContext, string name)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);
            ArgumentUtility.CheckNotNullOrEmpty("name", name);

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Type, "checkbox");

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Name, name);

            if (renderingContext.Control.EditModeController.IsRowEditModeActive)
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
            }

            string alternateText = renderingContext.Control.GetResourceManager().GetString(BocList.ResourceIdentifier.SelectAllRowsAlternateText);

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Alt, alternateText);

            if (renderingContext.Control.HasClientScript)
            {
                string script = "BocList_OnSelectAllSelectorControlClick ("
                                + "document.getElementById ('" + renderingContext.Control.ClientID + "'), "
                                + "this);";
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Onclick, script);
            }

            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Input);
            renderingContext.Writer.RenderEndTag();
        }
Ejemplo n.º 6
0
        public void RenderDataCell(BocListRenderingContext renderingContext, BocListRowRenderingContext rowRenderingContext, string cssClassTableCell)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);
            ArgumentUtility.CheckNotNull("cssClassTableCell", cssClassTableCell);
            ArgumentUtility.CheckNotNullOrEmpty("cssClassTableCell", cssClassTableCell);

            if (!renderingContext.Control.IsSelectionEnabled)
            {
                return;
            }

            string selectorControlID    = renderingContext.Control.GetSelectorControlName().Replace('$', '_') + "_" + rowRenderingContext.Row.Index;
            var    selectorControlName  = renderingContext.Control.GetSelectorControlName();
            var    selectorControlValue = renderingContext.Control.GetSelectorControlValue(rowRenderingContext.Row);
            var    isChecked            = rowRenderingContext.IsSelected;

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClassTableCell);
            if (_renderingFeatures.EnableDiagnosticMetadata)
            {
                AddDiagnosticMetadataListCellIndex(renderingContext);
            }
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Td);
            RenderDataRowSelectorControl(renderingContext, selectorControlID, selectorControlName, selectorControlValue, isChecked);
            renderingContext.Writer.RenderEndTag();
        }
        /// <summary> Renders the column group, which provides the table's column layout. </summary>
        private void RenderTableBlockColumnGroup(BocListRenderingContext renderingContext)
        {
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Colgroup);

            bool isTextXml = false;

            if (!renderingContext.Control.IsDesignMode)
            {
                isTextXml = ControlHelper.IsXmlConformResponseTextRequired(renderingContext.HttpContext);
            }

            RenderIndexColumnDeclaration(renderingContext, isTextXml);
            RenderSelectorColumnDeclaration(renderingContext, isTextXml);

            foreach (var columnRenderer in renderingContext.ColumnRenderers)
            {
                columnRenderer.RenderDataColumnDeclaration(renderingContext, isTextXml);
            }

            //  Design-mode and empty table
            if (ControlHelper.IsDesignMode(renderingContext.Control) && renderingContext.ColumnRenderers.Length == 0)
            {
                for (int i = 0; i < BocRowRenderer.DesignModeDummyColumnCount; i++)
                {
                    renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Col);
                    renderingContext.Writer.RenderEndTag();
                }
            }

            renderingContext.Writer.RenderEndTag();
        }
Ejemplo n.º 8
0
        private void RegisterInitializeListScript(BocListRenderingContext renderingContext)
        {
            if (renderingContext.Control.HasClientScript)
            {
                //  Render the init script for the client side selection handling

                bool hasClickSensitiveRows = renderingContext.Control.IsSelectionEnabled && !renderingContext.Control.EditModeController.IsRowEditModeActive &&
                                             renderingContext.Control.AreDataRowsClickSensitive();

                const string scriptTemplate = "BocList_InitializeList ( $('#{0}')[0], '{1}', '{2}', {3}, {4}, {5});";
                string       script         = string.Format(
                    scriptTemplate,
                    renderingContext.Control.ClientID,
                    renderingContext.Control.GetSelectorControlName(),
                    renderingContext.Control.GetSelectAllControlName(),
                    (int)renderingContext.Control.Selection,
                    hasClickSensitiveRows ? "true" : "false",
                    renderingContext.Control.GetSelectionChangedHandlerScript());

                renderingContext.Control.Page.ClientScript.RegisterStartupScriptBlock(
                    renderingContext.Control,
                    typeof(BocListTableBlockRenderer),
                    typeof(BocList).FullName + "_" + renderingContext.Control.ClientID + "_InitializeListScript",
                    script);
            }
        }
Ejemplo n.º 9
0
        public void RenderTitleCell(BocListRenderingContext renderingContext)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);

            if (!renderingContext.Control.IsSelectionEnabled)
            {
                return;
            }

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClasses.TitleCell);
            if (_renderingFeatures.EnableDiagnosticMetadata)
            {
                AddDiagnosticMetadataListCellIndex(renderingContext);
            }
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Th);
            if (renderingContext.Control.Selection == RowSelection.Multiple)
            {
                string selectorControlName = renderingContext.Control.GetSelectAllControlName();
                if (_renderingFeatures.EnableDiagnosticMetadata)
                {
                    renderingContext.Writer.AddAttribute(DiagnosticMetadataAttributesForObjectBinding.BocListWellKnownSelectAllControl, "true");
                }
                RenderTitleRowSelectorControl(renderingContext, selectorControlName);
            }
            else
            {
                renderingContext.Writer.Write(c_whiteSpace);
            }
            renderingContext.Writer.RenderEndTag();
        }
        public void RenderDataCell(BocListRenderingContext renderingContext, int originalRowIndex, int absoluteRowIndex, string cssClassTableCell)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);
            ArgumentUtility.CheckNotNull("cssClassTableCell", cssClassTableCell);

            if (!renderingContext.Control.IsIndexEnabled)
            {
                return;
            }

            string selectorControlID = renderingContext.Control.GetSelectorControlName().Replace('$', '_') + "_" + originalRowIndex;
            string cssClass          = cssClassTableCell + " " + CssClasses.DataCellIndex;

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass);
            if (_renderingFeatures.EnableDiagnosticMetadata)
            {
                AddDiagnosticMetadataListCellIndex(renderingContext);
            }
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Td);
            if (renderingContext.Control.Index == RowIndex.InitialOrder)
            {
                RenderRowIndex(renderingContext, originalRowIndex, selectorControlID);
            }
            else if (renderingContext.Control.Index == RowIndex.SortedOrder)
            {
                RenderRowIndex(renderingContext, absoluteRowIndex, selectorControlID);
            }
            renderingContext.Writer.RenderEndTag();
        }
Ejemplo n.º 11
0
        public void RenderTitlesRow(BocListRenderingContext renderingContext)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);

            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            GetIndexColumnRenderer().RenderTitleCell(renderingContext);
            GetSelectorColumnRenderer().RenderTitleCell(renderingContext);

            foreach (var columnRenderer in renderingContext.ColumnRenderers)
            {
                columnRenderer.RenderTitleCell(renderingContext);
            }

            if (ControlHelper.IsDesignMode(renderingContext.Control) && renderingContext.ColumnRenderers.Length == 0)
            {
                for (int i = 0; i < DesignModeDummyColumnCount; i++)
                {
                    renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    renderingContext.Writer.Write(String.Format(DesignModeDummyColumnTitle, i + 1));
                    renderingContext.Writer.RenderEndTag();
                }
            }

            renderingContext.Writer.RenderEndTag();
        }
        /// <summary> Renderes the closing tag of the table. </summary>
        private void RenderTableClosingTag(BocListRenderingContext renderingContext)
        {
            renderingContext.Writer.RenderEndTag(); // table

            renderingContext.Writer.RenderEndTag(); // div TableScrollContainer

            renderingContext.Writer.RenderEndTag(); // div TableContainer
        }
        /// <summary>
        /// Renders the data row of the <see cref="BocList"/>.
        /// </summary>
        /// <remarks>
        /// This method provides the outline of the table head, actual rendering of each row is delegated to
        /// <see cref="BocRowRenderer.RenderTitlesRow"/>.
        /// The rows are nested within a &lt;thead&gt; element.
        /// </remarks>
        /// <seealso cref="BocRowRenderer"/>
        protected virtual void RenderTableHead(BocListRenderingContext renderingContext)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClasses.TableHead);
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Thead);
            RowRenderer.RenderTitlesRow(renderingContext);
            renderingContext.Writer.RenderEndTag();
        }
        /// <summary> Renderes the opening tag of the table. </summary>
        private void RenderTableOpeningTag(BocListRenderingContext renderingContext)
        {
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClasses.TableContainer);
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Div);

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClasses.TableScrollContainer);
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Id, renderingContext.Control.ClientID + "_TableScrollContainer");
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Div);

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClasses.Table);
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Table);
        }
 private void RenderEmptyTable(BocListRenderingContext renderingContext)
 {
     renderingContext.Writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
     renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
     renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
     renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Table);
     renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Tr);
     renderingContext.Writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
     renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Td);
     renderingContext.Writer.Write("&nbsp;");
     renderingContext.Writer.RenderEndTag();
     renderingContext.Writer.RenderEndTag();
     renderingContext.Writer.RenderEndTag();
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Renders the <see cref="BocList"/> to the <see cref="HtmlTextWriter"/> in the Writer property.
        /// </summary>
        /// <remarks>
        /// This method provides the outline table of the <see cref="BocList"/>, creating three areas:
        /// <list type="bullet">
        /// <item><description>A table block displaying the title and data rows. See <see cref="IBocListTableBlockRenderer.Render"/>.</description></item>
        /// <item><description>A menu block containing the available commands. See <see cref="IBocListMenuBlockRenderer.Render"/></description></item>
        /// <item><description>A navigation block to browse through pages of data rows. See <see cref="IBocListNavigationBlockRenderer.Render"/>.</description></item>
        /// </list>
        /// </remarks>
        /// <seealso cref="BocListMenuBlockRenderer"/>
        /// <seealso cref="BocListNavigationBlockRenderer"/>
        public void Render(BocListRenderingContext renderingContext)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);

            RegisterInitializeGlobalsScript(renderingContext);

            AddAttributesToRender(renderingContext);
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Div);

            RenderContents(renderingContext);

            renderingContext.Writer.RenderEndTag();

            RegisterInitializeListScript(renderingContext);
        }
        private void RenderOptionsMenu(BocListRenderingContext renderingContext, string menuBlockItemOffset)
        {
            if (!renderingContext.Control.HasOptionsMenu)
            {
                return;
            }

            Assertion.IsTrue(
                renderingContext.Control.OptionsMenu.Visible,
                "BocList '{0}': The OptionsMenu must remain visible if BocList.HasOptionsMenu is evaluates 'true'.",
                renderingContext.Control.ID);

            renderingContext.Control.OptionsMenu.Style.Add("margin-bottom", menuBlockItemOffset);
            renderingContext.Control.OptionsMenu.RenderControl(renderingContext.Writer);
        }
Ejemplo n.º 18
0
        private void RegisterInitializeGlobalsScript(BocListRenderingContext renderingContext)
        {
            if (!renderingContext.Control.HasClientScript)
            {
                return;
            }

            string startUpScriptKey = typeof(BocListRenderer).FullName + "_Startup";

            if (!renderingContext.Control.Page.ClientScript.IsStartupScriptRegistered(typeof(BocListRenderer), startUpScriptKey))
            {
                string script = "BocList_InitializeGlobals ();";
                renderingContext.Control.Page.ClientScript.RegisterStartupScriptBlock(
                    renderingContext.Control, typeof(BocListRenderer), startUpScriptKey, script);
            }
        }
        /// <summary>
        /// Renders the navigation bar consisting of the move buttons and the current-page field.
        /// </summary>
        public void Render(BocListRenderingContext renderingContext)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClasses.Navigator);
            if (IsDiagnosticMetadataRenderingEnabled)
            {
                renderingContext.Writer.AddAttribute(
                    DiagnosticMetadataAttributesForObjectBinding.BocListNumberOfPages,
                    renderingContext.Control.PageCount.ToString());
            }
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Div);

            if (renderingContext.Control.HasClientScript)
            {
                bool isFirstPage = renderingContext.Control.CurrentPageIndex == 0;
                bool isLastPage  = renderingContext.Control.CurrentPageIndex + 1 >= renderingContext.Control.PageCount;

                var isReadOnly = renderingContext.Control.PageCount == 1 || renderingContext.Control.EditModeController.IsRowEditModeActive;

                if (isReadOnly)
                {
                    RenderPageInformationReadOnly(renderingContext);
                }
                else
                {
                    RenderPageInformation(renderingContext);
                }

                RenderNavigationIcon(renderingContext, isFirstPage || isReadOnly, GoToOption.First, 0);
                RenderNavigationIcon(renderingContext, isFirstPage || isReadOnly, GoToOption.Previous, renderingContext.Control.CurrentPageIndex - 1);
                RenderNavigationIcon(renderingContext, isLastPage || isReadOnly, GoToOption.Next, renderingContext.Control.CurrentPageIndex + 1);
                RenderNavigationIcon(renderingContext, isLastPage || isReadOnly, GoToOption.Last, renderingContext.Control.PageCount - 1);

                if (!isReadOnly)
                {
                    RenderValueField(renderingContext);
                }
            }
            else
            {
                RenderPageInformationReadOnly(renderingContext);
            }

            renderingContext.Writer.RenderEndTag();
        }
        private void RenderPageInformationReadOnly(BocListRenderingContext renderingContext)
        {
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Span);

            //  Page info
            string pageLabelText      = GetResourceManager(renderingContext).GetString(ResourceIdentifier.PageLabelText);
            string totalPageCountText = GetResourceManager(renderingContext).GetString(ResourceIdentifier.TotalPageCountText);

            // Do not HTML encode.
            renderingContext.Writer.Write(pageLabelText);
            renderingContext.Writer.Write(" ");
            renderingContext.Writer.Write(renderingContext.Control.CurrentPageIndex + 1);
            renderingContext.Writer.Write(" ");
            renderingContext.Writer.Write(totalPageCountText, renderingContext.Control.PageCount);

            renderingContext.Writer.RenderEndTag(); // end span
        }
        /// <summary> Renders the menu block of the control. </summary>
        /// <remarks> Contains the drop down list for selcting a column configuration and the options menu.  </remarks>
        public void Render(BocListRenderingContext renderingContext)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);

            string menuBlockItemOffset = c_defaultMenuBlockItemOffset;

            if (!renderingContext.Control.MenuBlockItemOffset.IsEmpty)
            {
                menuBlockItemOffset = renderingContext.Control.MenuBlockItemOffset.ToString();
            }

            RenderAvailableViewsList(renderingContext, menuBlockItemOffset);

            RenderOptionsMenu(renderingContext, menuBlockItemOffset);

            RenderListMenu(renderingContext, menuBlockItemOffset);
        }
Ejemplo n.º 22
0
        public void RenderEmptyListDataRow(BocListRenderingContext renderingContext)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);

            BocColumnRenderer[] columnRenderers = renderingContext.ColumnRenderers;
            int columnCount = 0;

            if (renderingContext.Control.IsIndexEnabled)
            {
                columnCount++;
            }

            if (renderingContext.Control.IsSelectionEnabled)
            {
                columnCount++;
            }

            for (int idxColumns = 0; idxColumns < columnRenderers.Length; idxColumns++)
            {
                BocColumnRenderer columnRenderer = columnRenderers[idxColumns];
                if (columnRenderer.IsVisibleColumn)
                {
                    columnCount++;
                }
            }

            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnCount.ToString());
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Td);

            string emptyListMessage;

            if (string.IsNullOrEmpty(renderingContext.Control.EmptyListMessage))
            {
                emptyListMessage = renderingContext.Control.GetResourceManager().GetString(BocList.ResourceIdentifier.EmptyListMessage);
            }
            else
            {
                emptyListMessage = renderingContext.Control.EmptyListMessage;
            }
            // Do not HTML encode
            renderingContext.Writer.Write(emptyListMessage);

            renderingContext.Writer.RenderEndTag();
            renderingContext.Writer.RenderEndTag();
        }
Ejemplo n.º 23
0
        protected virtual void RenderContents(BocListRenderingContext renderingContext)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);

            //  Menu Block
            if (renderingContext.Control.HasMenuBlock)
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClasses.MenuBlock);

                if (!renderingContext.Control.MenuBlockWidth.IsEmpty)
                {
                    renderingContext.Writer.AddStyleAttribute(HtmlTextWriterStyle.Width, renderingContext.Control.MenuBlockWidth.ToString());
                }

                renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Div);

                if (!renderingContext.Control.MenuBlockOffset.IsEmpty)
                {
                    renderingContext.Writer.AddStyleAttribute(HtmlTextWriterStyle.MarginLeft, renderingContext.Control.MenuBlockOffset.ToString());
                }
                renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Div);

                MenuBlockRenderer.Render(renderingContext);

                renderingContext.Writer.RenderEndTag();
                renderingContext.Writer.RenderEndTag();
            }

            //  Table Block
            renderingContext.Writer.AddAttribute(
                HtmlTextWriterAttribute.Class, CssClasses.GetTableBlock(renderingContext.Control.HasMenuBlock, renderingContext.Control.HasNavigator));
            if (renderingContext.Control.HasMenuBlock && !renderingContext.Control.MenuBlockWidth.IsEmpty)
            {
                renderingContext.Writer.AddStyleAttribute("right", renderingContext.Control.MenuBlockWidth.ToString());
            }
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Div);

            TableBlockRenderer.Render(renderingContext);

            if (renderingContext.Control.HasNavigator)
            {
                NavigationBlockRenderer.Render(renderingContext);
            }

            renderingContext.Writer.RenderEndTag();
        }
Ejemplo n.º 24
0
        public void RenderDataRow(BocListRenderingContext renderingContext, BocListRowRenderingContext rowRenderingContext, int rowIndex)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);
            ArgumentUtility.CheckNotNull("rowRenderingContext", rowRenderingContext);

            var absoluteRowIndex = rowRenderingContext.SortedIndex;
            var originalRowIndex = rowRenderingContext.Row.Index;
            var businessObject   = rowRenderingContext.Row.BusinessObject;

            bool isChecked = rowRenderingContext.IsSelected;
            bool isOddRow  = (rowIndex % 2 == 0); // row index is zero-based here, but one-based in rendering => invert even/odd

            var dataRowRenderEventArgs = new BocListDataRowRenderEventArgs(
                originalRowIndex,
                businessObject,
                true,
                isOddRow);

            renderingContext.Control.OnDataRowRendering(dataRowRenderEventArgs);

            string cssClassTableRow  = GetCssClassTableRow(renderingContext, isChecked, dataRowRenderEventArgs);
            string cssClassTableCell = CssClasses.DataCell;

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClassTableRow);
            if (_renderingFeatures.EnableDiagnosticMetadata)
            {
                // Note: business objects without identity can already be selected via row index.
                var businessObjectWithIdentity = rowRenderingContext.Row.BusinessObject as IBusinessObjectWithIdentity;
                if (businessObjectWithIdentity != null)
                {
                    renderingContext.Writer.AddAttribute(DiagnosticMetadataAttributes.ItemID, businessObjectWithIdentity.UniqueIdentifier);
                }

                var oneBasedRowIndex = rowIndex + 1;
                renderingContext.Writer.AddAttribute(DiagnosticMetadataAttributesForObjectBinding.BocListRowIndex, oneBasedRowIndex.ToString());
            }
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            GetIndexColumnRenderer().RenderDataCell(renderingContext, originalRowIndex, absoluteRowIndex, cssClassTableCell);
            GetSelectorColumnRenderer().RenderDataCell(renderingContext, rowRenderingContext, cssClassTableCell);

            RenderDataCells(renderingContext, rowIndex, dataRowRenderEventArgs);

            renderingContext.Writer.RenderEndTag();
        }
        private void RenderListMenu(BocListRenderingContext renderingContext, string menuBlockItemOffset)
        {
            if (!renderingContext.Control.HasListMenu)
            {
                return;
            }

            Assertion.IsTrue(
                renderingContext.Control.ListMenu.Visible,
                "BocList '{0}': The ListMenu must remain visible if BocList.HasListMenu is evaluates 'true'.",
                renderingContext.Control.ID);

            renderingContext.Writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
            renderingContext.Writer.AddStyleAttribute("margin-bottom", menuBlockItemOffset);
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Div);
            renderingContext.Control.ListMenu.RenderControl(renderingContext.Writer);
            renderingContext.Writer.RenderEndTag();
        }
        /// <summary>
        /// Renders the data contained in <see cref="IBocList"/> as a table.
        /// </summary>
        /// <remarks>
        /// The table consists of a title row showing the column titles, and a data row for each <see cref="IBusinessObject"/>
        /// in <see cref="IBocList"/>. If there is no data, the table will be completely hidden (only one cell containing only whitespace)
        /// if <see cref="Remotion.ObjectBinding.Web.UI.Controls.BocList.ShowEmptyListEditMode"/> is <see langword="false"/> and
        /// <see cref="IBocList"/> is editable
        /// or if <see cref="Remotion.ObjectBinding.Web.UI.Controls.BocList.ShowEmptyListReadOnlyMode"/> is <see langword="false"/> and
        /// <see cref="IBocList"/> is read-only.
        /// Exception: at design time, the title row will always be visible.
        /// </remarks>
        /// <seealso cref="RenderTableBlockColumnGroup"/>
        /// <seealso cref="RenderTableBody"/>
        public void Render(BocListRenderingContext renderingContext)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);

            bool isDesignMode     = ControlHelper.IsDesignMode(renderingContext.Control);
            bool isReadOnly       = renderingContext.Control.IsReadOnly;
            bool showForEmptyList = isReadOnly && renderingContext.Control.ShowEmptyListReadOnlyMode ||
                                    !isReadOnly && renderingContext.Control.ShowEmptyListEditMode;

            if (!renderingContext.Control.HasValue && !showForEmptyList)
            {
                RenderTable(renderingContext, isDesignMode, false);
            }
            else
            {
                RenderTable(renderingContext, true, true);
            }
        }
 /// <summary>Renders the col element for the index column</summary>
 private void RenderIndexColumnDeclaration(BocListRenderingContext renderingContext, bool isTextXml)
 {
     if (renderingContext.Control.IsIndexEnabled)
     {
         renderingContext.Writer.WriteBeginTag("col");
         renderingContext.Writer.Write(" style=\"");
         renderingContext.Writer.WriteStyleAttribute("width", "1.6em");
         renderingContext.Writer.Write("\"");
         if (isTextXml)
         {
             renderingContext.Writer.Write(" />");
         }
         else
         {
             renderingContext.Writer.Write(">");
         }
     }
 }
        private void RenderAvailableViewsList(BocListRenderingContext renderingContext, string menuBlockItemOffset)
        {
            if (!renderingContext.Control.HasAvailableViewsList)
            {
                return;
            }

            renderingContext.Writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
            renderingContext.Writer.AddStyleAttribute("margin-bottom", menuBlockItemOffset);
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Div);
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClasses.AvailableViewsListLabel);

            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Span);
            string availableViewsListTitle;

            if (string.IsNullOrEmpty(renderingContext.Control.AvailableViewsListTitle))
            {
                availableViewsListTitle = renderingContext.Control.GetResourceManager().GetString(Controls.BocList.ResourceIdentifier.AvailableViewsListTitle);
            }
            else
            {
                availableViewsListTitle = renderingContext.Control.AvailableViewsListTitle;
            }
            // Do not HTML encode.
            renderingContext.Writer.Write(availableViewsListTitle);
            renderingContext.Writer.RenderEndTag();

            renderingContext.Writer.Write(c_whiteSpace);

            var availableViewsList = renderingContext.Control.GetAvailableViewsList();

            if (renderingContext.Control.IsDesignMode)
            {
                availableViewsList.Width = Unit.Point(c_designModeAvailableViewsListWidthInPoints);
            }
            availableViewsList.Enabled = !renderingContext.Control.EditModeController.IsRowEditModeActive &&
                                         !renderingContext.Control.EditModeController.IsListEditModeActive;
            availableViewsList.CssClass = CssClasses.AvailableViewsListDropDownList;
            availableViewsList.RenderControl(renderingContext.Writer);

            renderingContext.Writer.RenderEndTag();
        }
Ejemplo n.º 29
0
        private void RenderDataRowSelectorControl(BocListRenderingContext renderingContext, string id, string name, string value, bool isChecked)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);
            ArgumentUtility.CheckNotNullOrEmpty("id", id);
            ArgumentUtility.CheckNotNullOrEmpty("name", name);


            if (renderingContext.Control.Selection == RowSelection.SingleRadioButton)
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Type, "radio");
            }
            else
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Type, "checkbox");
            }

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Id, id);
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Name, name);

            if (isChecked)
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Checked, "checked");
            }
            if (renderingContext.Control.EditModeController.IsRowEditModeActive)
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
            }
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Value, value);

            string alternateText = renderingContext.Control.GetResourceManager().GetString(BocList.ResourceIdentifier.SelectRowAlternateText);

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Alt, alternateText);

            if (renderingContext.Control.HasClientScript)
            {
                const string script = "BocList_OnSelectionSelectorControlClick();";
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Onclick, script);
            }

            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Input);
            renderingContext.Writer.RenderEndTag();
        }
        private void RenderValueField(BocListRenderingContext renderingContext)
        {
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Id, GetCurrentPageIndexControlID(renderingContext));
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Name, renderingContext.Control.GetCurrentPageControlName());
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Type, "hidden");
            renderingContext.Writer.AddAttribute(
                HtmlTextWriterAttribute.Value,
                renderingContext.Control.CurrentPageIndex.ToString(CultureInfo.InvariantCulture));

            var postBackOptions = new PostBackOptions(new Control {
                ID = renderingContext.Control.GetCurrentPageControlName()
            }, "");

            renderingContext.Writer.AddAttribute(
                HtmlTextWriterAttribute.Onchange,
                renderingContext.Control.Page.ClientScript.GetPostBackEventReference(postBackOptions));

            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Input);
            renderingContext.Writer.RenderEndTag();
        }