Ejemplo n.º 1
0
        protected virtual void RenderCellValue(GridColumn <T> column, GridRowViewData <T> rowData)
        {
            if (!string.IsNullOrEmpty(column.Name) && (column.Name == "rowNum" || column.Name == "LineNum"))
            {
                RenderText(RenderRowNum());
            }
            else
            {
                var cellValue = column.GetValue(rowData.Item);

                if (column.IsEditable && column.Selectable)
                {
                    cellValue = string.Format("<input type=\"text\" value=\"{0}\" class=\"search-text\"><a class=\"si-btn search\"></a>", cellValue);
                }
                else if (column.Selectable)
                {
                    cellValue = string.Format("<input type=\"text\" value=\"{0}\" class=\"search-text\" disabled=\"disabled\"><a class=\"si-btn search\"></a>", cellValue);
                }
                else if (column.IsEditable)
                {
                    cellValue = string.Format("<input type=\"text\" value=\"{0}\" class=\"focus\">", cellValue);
                }

                if (cellValue != null)
                {
                    RenderText(cellValue.ToString());
                }
            }
        }
        protected override void RenderStartCell(GridColumn <T> column, GridRowViewData <T> rowData)
        {
            //add by zhangh 2013/06/17 增加对齐方式
            IDictionary <string, object> attributes = column.Attributes(rowData);

            if (column.Alignment == Alignment.Center)
            {
                attributes.Add("class", "text-align-center");
            }
            else if (column.Alignment == Alignment.Right)
            {
                attributes.Add("class", "text-align-right");
            }
            else
            {
                attributes.Add("class", "text-align-left");
            }

            attributes.Add("field", column.FieldName);
            if (!column.IsHide)
            {
                attributes.Add("width", column.ColWidth);
            }

            if (column.IsEditable)
            {
                attributes.Add("editable", "true");
            }

            if (column.Selectable)
            {
                attributes.Add("selectable", "true");
            }

            if (column.Reliable)
            {
                attributes.Add("reliable", "true");
            }

            if (column.IsSumColumn)
            {
                attributes.Add("issum", "true");
            }

            if (!string.IsNullOrEmpty(column.ColumnEqualTo))
            {
                attributes.Add("equalto", column.ColumnEqualTo);
            }

            string attrs = BuildHtmlAttributes(attributes);

            if (attrs.Length > 0)
            {
                attrs = " " + attrs;
            }

            RenderText(string.Format("<td{0}>", attrs));
        }
Ejemplo n.º 3
0
        protected void BaseRenderRowEnd(GridRowViewData <T> rowData)
        {
            bool rendered = GridModel.Sections.Row.EndSectionRenderer(rowData, new RenderingContext(Writer, Context, _engines));

            if (!rendered)
            {
                RenderRowEnd();
            }
        }
Ejemplo n.º 4
0
        private IDictionary <string, object> GetAttributesFromRow(GridRowViewData <T> row)
        {
            var dictionary = new Dictionary <string, object>();
            var pairs      = _attributes.SelectMany(attributeFunc => attributeFunc(row));

            foreach (var pair in pairs)
            {
                dictionary[pair.Key] = pair.Value;
            }

            return(dictionary);
        }
        protected override void RenderRowStart(GridRowViewData <T> rowData)
        {
            var attributes = GridModel.Sections.Row.Attributes(rowData);

            if (!attributes.ContainsKey("class"))
            {
                attributes["class"] = rowData.IsAlternate ? "gridrow_alternate" : "gridrow";
            }

            string attributeString = BuildHtmlAttributes(attributes);

            if (attributeString.Length > 0)
            {
                attributeString = " " + attributeString;
            }

            RenderText(string.Format("<tr{0}>", attributeString));
        }
Ejemplo n.º 6
0
        protected virtual void RenderItem(GridRowViewData <T> rowData)
        {
            BaseRenderRowStart(rowData);

            int i = 0;

            foreach (var column in VisibleColumns())
            {
                //A custom item section has been specified - render it and continue to the next iteration.
#pragma warning disable 612,618
                // TODO: CustomItemRenderer is obsolete in favour of custom columns. Remove this after next release.
                if (column.CustomItemRenderer != null)
                {
                    column.CustomItemRenderer(new RenderingContext(Writer, Context, _engines), rowData.Item);
                    continue;
                }
#pragma warning restore 612,618

                RenderStartCell(column, rowData);
                if (this.GridModel.ShowCheckBox && i == 0)
                {
                    RenderCheckBox(column, rowData.Item);
                }
                else
                {
                    RenderCellValue(column, rowData);
                }
                i++;

                if (i == VisibleColumns().Count())
                {
                    i = 0;
                }

                RenderEndCell();
            }

            BaseRenderRowEnd(rowData);
        }
Ejemplo n.º 7
0
 protected abstract void RenderStartCell(GridColumn <T> column, GridRowViewData <T> rowViewData);
Ejemplo n.º 8
0
 protected abstract void RenderRowStart(GridRowViewData <T> rowData);