public BootstrapQueryHelperColumn AddColumn(string name, string caption, Formatter formatter)
        {
            BootstrapQueryHelperColumn col = new BootstrapQueryHelperColumn()
            {
                Name      = name,
                Caption   = caption,
                Formatter = formatter
            };

            this.columns.Add(col);
            return(col);
        }
        private HtmlComposite BuildTableBody <T>(ClassSelectResult <T> result)
        {
            ClassSchema <T> aspect = ClassSchema <T> .Instance;

            HtmlComposite tbody = new HtmlComposite("tbody");

            AspectMember[] onclickMembers =
                OnClickColumns != null && OnClickColumns.Length > 0 ?
                new AspectMember[OnClickColumns.Length] : null;

            if (onclickMembers != null)
            {
                for (int i = 0; i < onclickMembers.Length; i++)
                {
                    onclickMembers[i] = aspect[OnClickColumns[i]];
                }
            }

            object[] onclickValues =
                OnClickColumns != null && OnClickColumns.Length > 0 ?
                new object[OnClickColumns.Length] : null;

            AspectMember[] members = new AspectMember[columns.Count];
            for (int i = 0; i < members.Length; i++)
            {
                members[i] = aspect[columns[i].Name];
            }

            foreach (T child in result)
            {
                HtmlComposite tr = tbody.AppendComposite("tr");

                if (!string.IsNullOrEmpty(this.OnClickFormatString))
                {
                    if (onclickValues != null)
                    {
                        for (int i = 0; i < onclickValues.Length; i++)
                        {
                            onclickValues[i] = onclickMembers[i].GetValue(child);
                        }

                        tr
                        .AppendAttribute("style", "cursor:pointer")
                        .AppendAttribute("onclick", string.Format(this.OnClickFormatString, onclickValues));
                    }
                    else
                    {
                        tr
                        .AppendAttribute("style", "cursor:pointer")
                        .AppendAttribute("onclick", this.OnClickFormatString);
                    }
                }


                for (int i = 0; i < members.Length; i++)
                {
                    BootstrapQueryHelperColumn col = columns[i];

                    HtmlComposite td = tr.AppendComposite("td");
                    if (!string.IsNullOrEmpty(col.CssStyle))
                    {
                        td.AppendAttribute("style", col.CssStyle);
                    }
                    if (!string.IsNullOrEmpty(col.CssClass))
                    {
                        td.AppendAttribute("class", col.CssClass);
                    }

                    object value   = members[i].GetValue(child);
                    string content = col.Formatter.Format(value, CultureInfo.CurrentUICulture);

                    if (col.IsHtmlRaw)
                    {
                        td.Children.AddLast(new HtmlRaw(content));
                    }
                    else
                    {
                        td.AppendText(content);
                    }
                }
            }

            return(tbody);
        }