Beispiel #1
0
        private void GenerateHtmlWithoutRow(StringBuilder sb, GenearetHtml handler)
        {
            var id = GetNextID();

            _parity = !_parity;
            foreach (var column in Columns.Where(p => p.Visible && (p.VisiblePermissions == null || UserRoles.IsInAnyRoles(p.VisiblePermissions))))
            {
                if (column is GridHtmlGenerator.ButtonsColumn)
                {
                    sb.Append("<td class=\"gridActionCellIsSelectedAsRow\" style=\"display:none\" id=\"buttons_");
                    sb.Append(id);
                }
                else
                {
                    if (column.ColumnValueHandler != null && column.ColumnValueHandler() == null)
                    {
                        continue;
                    }
                    sb.Append("<td style=\"cursor:hand;\" onclick=\"javascript:_selectCell(this,");
                    sb.Append(id);
                    sb.Append(");\" keyID=\"");
                    sb.Append(id);
                    sb.Append("\" class=\"");
                    sb.Append(_parity ? "gridCellIsNotSelectedAsRow1" : "gridCellIsNotSelectedAsRow2");
                }
                if (!string.IsNullOrEmpty(column.Width))
                {
                    sb.Append("\" width=\"");
                    sb.Append(column.Width);
                }
                sb.Append("\" parity=\"");
                sb.Append(_parity ? 1 : 0);
                sb.Append("\">");
                handler(sb, column);
                sb.Append("</td>");
            }
        }
Beispiel #2
0
        private void GenerateHtmlInMultipleRow(StringBuilder sb, string firstCssClass, string otherCssClass, GenearetHtml handler)
        {
            int colSpan = 0;

            sb.Append("<tr class=\"");
            sb.Append(firstCssClass);
            sb.Append("\">");

            var listSb = new List <StringBuilder>(CountRowsInOneRow)
            {
                sb
            };

            for (int i = 0; i < CountRowsInOneRow - 1; i++)
            {
                sb = new StringBuilder();
                sb.Append("<tr class=\"");
                sb.Append(otherCssClass);
                sb.Append("\">");
                listSb.Add(sb);
            }

            var columns = Columns
                          .Where(
                p => (p.VisiblePermissions == null || UserRoles.IsInAnyRoles(p.VisiblePermissions)) &&
                p.Visible);
            var countColumns = columns
                               .Count(
                r => r.ColumnName != "__icons" &&
                r.ColumnName != "__toChilds" &&
                r.ColumnName != "__buttons" &&
                r.RowIndex == 0);

            var countEmptyRows =
                columns.Count(
                    r =>
                    r.AsNewRow &&
                    (r.ColumnValueHandler() == null || string.Empty.Equals(r.ColumnValueHandler())));
            var countRowsInOneRow = CountRowsInOneRow - countEmptyRows;

            foreach (var column in columns)
            {
                if (column.ColumnName == "__icons" || column.ColumnName == "__toChilds")
                {
                    column.RowSpan = countRowsInOneRow;
                }

                sb = listSb[column.RowIndex];
                if (column.AsNewRow)
                {
                    if (column.ColumnValueHandler() == null || string.Empty.Equals(column.ColumnValueHandler()))
                    {
                        listSb[column.RowIndex] = null;
                        continue;
                    }

                    sb.Append("<td class='nat-headerInRow'>");
                    GridHtmlGenerator.RenderHeaderText(Page, Control, column, sb);
                    sb.Append("</td>");
                }

                colSpan--;
                if (colSpan > 0 || column.ColSpan == 0)
                {
                    continue;
                }
                if (!column.AsNewRow)
                {
                    colSpan = column.ColSpan;
                }
                else
                {
                    column.ColSpan = countColumns;
                }
                if (column.ColSpan > 1 || column.RowSpan > 1)
                {
                    sb.Append("<td");
                    if (column.ColSpan > 1)
                    {
                        sb.Append(" colspan=");
                        sb.Append(column.ColSpan);
                    }

                    if (column.RowSpan > 1)
                    {
                        sb.Append(" rowspan=");
                        sb.Append(column.RowSpan);
                    }

                    sb.Append(">");
                }
                else
                {
                    sb.Append("<td>");
                }
                handler(sb, column);
                sb.Append("</td>");
            }

            listSb[0].Append("</tr>");
            for (int i = 1; i < CountRowsInOneRow; i++)
            {
                if (listSb[i] != null)
                {
                    listSb[0].Append(listSb[i].ToString()).Append("</tr>");
                }
            }
        }
Beispiel #3
0
        private void GenerateHtmlInOneRow <TKey, TTable, TDataContext, TRow>(StringBuilder sb, string cssClass, string cssClass0, string cssClass1, GenearetHtml handler, BaseDataSourceView <TKey, TTable, TDataContext, TRow> view, TTable currentRow, SetDataRow <TRow> setDataRowDelegate, int countChilds, int allCountChilds, int level)
            where TKey : struct
            where TTable : class
            where TDataContext : DataContext, new()
            where TRow : BaseRow, new()
        {
            string id = view.GetStringID(currentRow);

            if (_loadedIDs.ContainsKey(id))
            {
                UsePostBackForChilds = false;
                GenerateHtmlInOneRow(sb, cssClass, null, handler);
            }
            else if ((
                         (LoadTreeCount >= allCountChilds && _sumCounts < MaxSumCounts) ||
                         countChilds <= MinCountNotCheckLoad
                         ) && level < MaxLevelTreeLoad && countChilds > 0)
            {
                _sumCounts          += countChilds;
                UsePostBackForChilds = false;
                GenerateHtmlInOneRow(sb, cssClass, null, handler);
                ChildsID.Add(id);
                _loadedIDs.Add(id, true);
                var          data             = view.GetDataByRefParent(currentRow);
                bool         class0           = true;
                PropertyInfo itemPropertyInfo = null;
                foreach (var row in data)
                {
                    if (itemPropertyInfo == null)
                    {
                        itemPropertyInfo = row.GetType().GetProperty("Item");
                    }
                    var count = row.CountChildsData();
                    setDataRowDelegate(row);
                    GenerateHtmlInOneRow(sb, class0 ? cssClass0 : cssClass1,
                                         cssClass0, cssClass1, handler, view,
                                         (TTable)itemPropertyInfo.GetValue(row, null), setDataRowDelegate,
                                         count, allCountChilds * count, level + 1);
                    class0 = !class0;
                }
                ChildsID.RemoveAt(ChildsID.Count - 1);
            }
            else
            {
                UsePostBackForChilds = true;
                GenerateHtmlInOneRow(sb, cssClass, null, handler);
            }
        }
Beispiel #4
0
        private void GenerateHtmlInOneRow(StringBuilder sb, string cssClass, string cssClassNotSelected, GenearetHtml handler)
        {
            int colSpan = 0;

            sb.AppendLine();
            int tabCount = ChildsID != null ? ChildsID.Count : 0;

            sb.Append('\t', tabCount);
            sb.AppendFormat("<tr class=\"{0}\" notSelectedCSS=\"{1}\"", cssClass, cssClassNotSelected);
            if (ChildsID != null)
            {
                if (ChildsID.Count > 0)
                {
                    sb.Append(" style=\"display:none\"");
                }
                sb.AppendFormat(" level=\"{0}\" parentID=\"{1}\"", ChildsID.Count, ChildsID.LastOrDefault());

                /*int i = 0;
                 * foreach (var childID in ChildsID)
                 * {
                 *  sb.Append(" level");
                 *  sb.Append(i);
                 *  sb.Append("=\"");
                 *  sb.Append(childID);
                 *  i++;
                 * }*/
            }
            sb.Append(">");
            sb.AppendLine();

            foreach (var column in Columns.Where(p => p.Visible && (p.VisiblePermissions == null || UserRoles.IsInAnyRoles(p.VisiblePermissions))))
            {
                colSpan--;
                if (colSpan > 0 || column.ColSpan == 0)
                {
                    continue;
                }
                var rowSpan = column.GetRowSpan();
                if (rowSpan < 0)
                {
                    continue;
                }

                var style = column.GetStyle();
                colSpan = column.ColSpan;
                sb.AppendLine();
                sb.Append('\t', tabCount + 1);
                sb.Append("<td");
                if (colSpan > 1)
                {
                    sb.Append(" colspan=");
                    sb.Append(colSpan);
                }
                if (rowSpan > 1)
                {
                    sb.Append(" rowspan=");
                    sb.Append(rowSpan);
                }

                if (!string.IsNullOrEmpty(style))
                {
                    sb.Append(" style=\"");
                    sb.Append(style);
                    sb.Append("\"");
                }

                sb.Append(">");

                handler(sb, column);
                sb.Append("</td>");
                sb.AppendLine();
            }

            sb.AppendLine();
            sb.Append('\t', tabCount);
            sb.AppendLine("</tr>");
        }