Ejemplo n.º 1
0
        public static TableRow <THelper> TableDataRow <THelper>(this ITableCellCreator <THelper> creator, params object[] content)
            where THelper : BootstrapHelper <THelper>
        {
            TableRow <THelper> row = new TableRow <THelper>(creator);

            foreach (object c in content)
            {
                row.AddChild(new TableData <THelper>(creator).AddContent(c));
            }
            return(row);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// WXY扩展-设置表格对象-数据
        /// </summary>
        /// <param name="report"></param>
        /// <param name="key"></param>
        /// <param name="data"></param>
        /// <param name="Caption"></param>
        public static void SetTableObject_Data(this Report report, string key, DataTable data, bool Caption = true)
        {
            var obj = report.FindObject(key);

            if (obj != null)
            {
                if (obj is TableObject)
                {
                    var tbObj = obj as TableObject;
                    tbObj.Border.Lines = BorderLines.All;
                    if (Caption)
                    {
                        var rowCaption = new TableRow();
                        data.Columns.Cast <DataColumn>().ToList().ForEach(col =>
                        {
                            rowCaption.AddChild(new TableCell {
                                Text = col.Caption, Border = new Border()
                                {
                                    Lines = BorderLines.All
                                }, HorzAlign = HorzAlign.Center, VertAlign = VertAlign.Center
                            });
                        });
                        tbObj.Rows.Add(rowCaption);
                    }

                    var rows = data.Rows.Cast <DataRow>().ToList();
                    rows.ForEach(row =>
                    {
                        var rowData = new TableRow();
                        foreach (var col in data.Columns)
                        {
                            var column = col as DataColumn;
                            rowData.AddChild(new TableCell {
                                Text = row[column] == null ? "" : row[column].ToString(), Border = new Border()
                                {
                                    Lines = BorderLines.All
                                }
                            });
                        }
                        tbObj.Rows.Add(rowData);
                    });
                }
            }
        }
Ejemplo n.º 3
0
        private void LoadTable(string name, Base parent)
        {
            string      description = GetObjectDescription(name);
            TableObject table       = ComponentsFactory.CreateTableObject(name, parent);

            LoadComponent(description, table);
            LoadSize(description, table);
            LoadBorder(description, table.Border);
            table.Style = GetPropertyValue("StyleName", description).Replace("\"", "");
            List <string> rowNames = GetChildNames(DEV_EXPRESS_TABLE_ROW, description);

            TableInfo tableInfo = new TableInfo();

            // Create table columns.
            int columnsCount = 0;

            foreach (string rowName in rowNames)
            {
                string        rowDescription = GetObjectDescription(rowName);
                List <string> cellNames      = GetChildNames(DEV_EXPRESS_TABLE_CELL, rowDescription);

                if (columnsCount < cellNames.Count)
                {
                    columnsCount = cellNames.Count;
                    tableInfo.Column.Clear();
                    foreach (string cellName in cellNames)
                    {
                        tableInfo.Column.Add(GetWeight(cellName));
                    }
                }
            }

            for (int i = 0; i < rowNames.Count; i++)
            {
                tableInfo.Row.Add(GetWeight(rowNames[i]));
            }

            for (int i = 0; i < columnsCount; i++)
            {
                TableColumn column = new TableColumn();

                column.Width = GetRowColumnSize(tableInfo.Column, i, table.Width);
                table.Columns.Add(column);
                column.CreateUniqueName();
            }

            // Create table rows.
            for (int i = 0; i < rowNames.Count; i++)
            {
                TableRow row = new TableRow();
                row.Name = rowNames[i];
                string rowDescription = GetObjectDescription(row.Name);

                row.Height = GetRowColumnSize(tableInfo.Row, i, table.Height);
                List <string> cellNames = GetChildNames(DEV_EXPRESS_TABLE_CELL, rowDescription);

                // Create table cell.
                foreach (string cellName in cellNames)
                {
                    TableCell cell = new TableCell();
                    cell.Name = cellName;
                    LoadTableCell(cellName, cell);
                    row.AddChild(cell);
                }
                table.Rows.Add(row);
            }
        }
Ejemplo n.º 4
0
        private void LoadTable(XmlNode node, Base parent)
        {
            TableObject table = ComponentsFactory.CreateTableObject(node.Name, parent);

            AddLocalizationItemsAttributes(node);
            LoadComponent(node, table);
            LoadSize(node, table);
            LoadBorder(node, table.Border);
            ApplyStyle(node, table);
            TableInfo tableInfo = new TableInfo();
            XmlNode   rowsNode  = FindChildNoteByName(node, "Rows");

            int columnsCount = 0;

            foreach (XmlNode row in rowsNode.ChildNodes)
            {
                XmlNode cells = FindChildNoteByName(row, "Cells");

                if (columnsCount < cells.ChildNodes.Count)
                {
                    columnsCount = cells.ChildNodes.Count;

                    foreach (XmlNode cell in cells.ChildNodes)
                    {
                        AddLocalizationItemsAttributes(cell);
                        tableInfo.Column.Add(UnitsConverter.SizeFToPixels(GetAttribute(cell, "Weight")));
                    }
                }
            }

            foreach (XmlNode row in rowsNode)
            {
                AddLocalizationItemsAttributes(row);
                tableInfo.Row.Add(UnitsConverter.SizeFToPixels(GetAttribute(row, "Weight")));
            }

            for (int i = 0; i < columnsCount; i++)
            {
                TableColumn column = new TableColumn();
                column.Width = GetRowColumnSize(tableInfo.Column, i, table.Width);
                table.Columns.Add(column);
                column.CreateUniqueName();
            }

            for (int i = 0; i < rowsNode.ChildNodes.Count; i++)
            {
                XmlNode rowNode = rowsNode.ChildNodes[i];

                TableRow row = new TableRow();
                row.Name   = GetAttribute(rowNode, "Name");
                row.Height = GetRowColumnSize(tableInfo.Row, i, table.Height);
                XmlNode cells = FindChildNoteByName(rowNode, "Cells");

                for (int j = 0; j < cells.ChildNodes.Count; j++)
                {
                    XmlNode   cellNode = cells.ChildNodes[j];
                    TableCell cell     = new TableCell();
                    LoadTableCell(cellNode, cell);
                    if (j == cells.ChildNodes.Count - 1 && cells.ChildNodes.Count < columnsCount)
                    {
                        cell.ColSpan = columnsCount - cells.ChildNodes.Count + 1;
                    }
                    row.AddChild(cell);
                }
                table.Rows.Add(row);
            }
        }