Exemple #1
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();
        }
        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();
        }