Esempio n. 1
0
        public virtual void SetBody <T>(List <T> data, params string[] columns) where T : IEntity
        {
            Body.ContentTags.Clear();

            if (data != null && data.Count > 0)
            {
                this.bindData   = data as List <IEntity>;
                this.setColumns = columns.ToList();
                int           colNum  = 0;
                int           rowNum  = 0;
                HierarchyTag  row     = null;
                HtmlTag       col     = null;
                StringBuilder builder = new StringBuilder(200);

                foreach (T obj in data)
                {
                    builder.Clear();
                    colNum = 0;
                    row    = new HierarchyTag("tr");
                    if (!string.IsNullOrWhiteSpace(this.RowClickEventString))
                    {
                        builder.Append(this.RowClickEventString);
                    }
                    foreach (string column in columns)
                    {
                        if (!string.IsNullOrWhiteSpace(this.RowClickEventString))
                        {
                            builder.Replace("{" + column + "}", Convert.ToString(obj.GetValue(column)));
                        }
                        col = new HtmlTag("td", Convert.ToString(obj.GetValue(column)));
                        row.ContentTags.Add(colNum++, col);
                    }

                    if (tdList != null && tdList.Count > 0)
                    {
                        StringBuilder tdContent = null;

                        foreach (string td in tdList)
                        {
                            tdContent = new StringBuilder(td);
                            foreach (string column in columns)
                            {
                                tdContent.Replace("{" + column + "}", Convert.ToString(obj.GetValue(column)));
                            }
                            col = new HtmlTag("td", tdContent.ToString());
                            row.ContentTags.Add(colNum++, col);
                        }
                    }

                    if (!string.IsNullOrWhiteSpace(this.RowClickEventString))
                    {
                        row.RootTag.AttributeSet("onclick", builder.ToString());
                    }
                    Body.ContentTags.Add(rowNum++, row);
                }

                this.IsBody = true;
            }
        }
Esempio n. 2
0
        public virtual void SetHeader(params string[] names)
        {
            Header.ContentTags.Clear();
            int          num  = 0;
            HierarchyTag temp = new HierarchyTag("tr");

            foreach (string name in names)
            {
                temp.ContentTags.Add(num++, new HtmlTag("th", name));
            }
            Header.ContentTags.Add(1, temp);
            this.IsHeader = true;
        }
Esempio n. 3
0
        public virtual void SetFooter(int rowNum, int title_size, string title, int value_size, object value)
        {
            HierarchyTag temp = null;

            if (!Footer.ContentTags.TryGetValue(rowNum, out temp))
            {
                temp = new HierarchyTag("tr");
            }
            var titleTag = new HtmlTag("th", title);

            titleTag.AttributeSet("colspan", title_size.ToString());
            var contentTag = new HtmlTag("td", value.ToString());

            contentTag.AttributeSet("colspan", value_size.ToString());
            temp.ContentTags.Add(this.FootNumber++, titleTag);
            temp.ContentTags.Add(this.FootNumber++, contentTag);
            this.IsFooter = true;
        }