protected override HtmlNode CreateInput(UI.UIControlState state)
        {
            HtmlComposite ul = new HtmlComposite("ul", new HtmlAttribute("class", "unstyled"));

            foreach (KeyValuePair<object, object> item in state.Options)
            {
                HtmlComposite li = new HtmlComposite("li");
                ul.Children.AddLast(li);
                
                
                string id = state.Name + "_" + item.Key;
                HtmlComposite label = new HtmlComposite("label", new HtmlAttribute("class", "checkbox"));
                li.Children.AddLast(label);

                HtmlStandalone checkbox = new HtmlStandalone("input",
                    new HtmlAttribute("type", "radio"),
                    new HtmlAttribute("id", id),
                    new HtmlAttribute("name", state.Name),
                    new HtmlAttribute("value", item.Key));

                if (state.Value.Equals(item.Key))
                    checkbox.Attributes.AddLast("checked", "checked");


                label.Children.AddLast(checkbox);
                label.Children.AddLast(new HtmlText(" " + item.Value));

            }

            return ul;
        }
        public void RenderSearchBox(TextWriter writer)
        {
            HtmlComposite col1 = new HtmlComposite("div", new HtmlAttribute("class", "col-xs-3"));

            HtmlComposite rowb1 = col1.AppendComposite("div", new HtmlAttribute("class", "row-fluid"));

            HtmlComposite cellb1 = rowb1.AppendComposite("div", new HtmlAttribute("class", "col-xs-10"));

            cellb1.AppendStandalone("input",
                                    new HtmlAttribute("type", "text"),
                                    new HtmlAttribute("placeholder", "Search"),
                                    new HtmlAttribute("name", _SearchFilter.Key),
                                    new HtmlAttribute("id", _SearchFilter.Key),
                                    new HtmlAttribute("class", "form-control changeReload"),
                                    new HtmlAttribute("value", _SearchFilter.Value));

            HtmlComposite cellb2 = rowb1.AppendComposite("div", new HtmlAttribute("class", "col-xs-2"));

            cellb2.AppendComposite("button",
                                   new HtmlAttribute("type", "text"),
                                   new HtmlAttribute("class", "btn btn-primary pull-right"))
            .AppendSimple("i", "",
                          new HtmlAttribute("class", "fa fa-search"));

            col1.Write(writer);
        }
        public void RenderPageDropDown(TextWriter writer)
        {
            HtmlComposite coldiv = new HtmlComposite("div", new HtmlAttribute("class", "col-xs-3"));

            HtmlComposite rowb1 = coldiv.AppendComposite("div", new HtmlAttribute("class", "row-fluid"));

            HtmlComposite cellb1 = rowb1.AppendComposite("div", new HtmlAttribute("class", "col-xs-6"));

            cellb1.AppendSimple("label", "Page Size", new HtmlAttribute("class", "control-label pull-right"));

            HtmlComposite cellb2 = rowb1.AppendComposite("div", new HtmlAttribute("class", "col-xs-6"));

            HtmlComposite dropdown = cellb2.AppendComposite(
                "select",
                new HtmlAttribute("name", _PageSize.Key),
                new HtmlAttribute("id", _PageSize.Key),
                new HtmlAttribute("class", "form-control changeReload"));

            for (int i = 10; i <= 50; i += 10)
            {
                dropdown.AppendHtmlOption(i, i.ToString(), i == _PageSize.Value);
            }

            coldiv.Write(writer);
        }
        protected override HtmlNode CreateInput(UI.UIControlState state)
        {
            HtmlComposite ul = new HtmlComposite("ul");

            System.Collections.IEnumerable items =
                state.Value is string ?
                ((string)state.Value).Split(',') :
                (System.Collections.IEnumerable)state.Value;

            foreach (KeyValuePair<object, object> item in state.Options)
            {
                HtmlComposite li = new HtmlComposite("li");
                ul.Children.AddLast(li);

                string id = state.Name + "_" + item.Key;

                li.Children.AddLast(new HtmlSimple("label", item.Value, new HtmlAttribute("for", id)));

                HtmlStandalone checkbox = new HtmlStandalone("input",
                    new HtmlAttribute("type", "checkbox"),
                    new HtmlAttribute("id", id),
                    new HtmlAttribute("name", state.Name),
                    new HtmlAttribute("value", item.Key));

                if (IsChecked(items, item.Key))
                    checkbox.Attributes.AddLast("checked", "checked");

                li.Children.AddLast(checkbox);
            }

            return ul;
        }
示例#5
0
        protected override HtmlNode CreateInput(UI.UIControlState state)
        {
            HtmlComposite ul = new HtmlComposite("ul");

            foreach (KeyValuePair <object, object> item in state.Options)
            {
                HtmlComposite li = new HtmlComposite("li");
                ul.Children.AddLast(li);

                string id = state.Name + "_" + item.Key;

                li.Children.AddLast(new HtmlSimple("label", item.Value, new HtmlAttribute("for", id)));

                HtmlStandalone checkbox = new HtmlStandalone("input",
                                                             new HtmlAttribute("type", "checkbox"),
                                                             new HtmlAttribute("id", id),
                                                             new HtmlAttribute("name", state.Name),
                                                             new HtmlAttribute("value", item.Key));

                if (state.Value == item.Key)
                {
                    checkbox.Attributes.AddLast("checked", "checked");
                }

                li.Children.AddLast(checkbox);
            }

            return(ul);
        }
        public static HtmlComposite AppendComposite(this HtmlComposite element, string tagName, params HtmlAttribute[] attributes)
        {
            HtmlComposite composite = new HtmlComposite(tagName, attributes);

            element.Children.AddLast(composite);
            return(composite);
        }
        private HtmlComposite BuildTableFooter <T>(ClassSelectResult <T> result)
        {
            HtmlComposite footer = new HtmlComposite("tfoot");

            HtmlComposite footerDiv = footer
                                      .AppendComposite("tr")
                                      .AppendComposite("td", new HtmlAttribute("colspan", "100"))
                                      .AppendComposite("div", new HtmlAttribute("class", "row-fluid"));

            if (result.RecordCount == 0)
            {
                footerDiv.AppendComposite("div", new HtmlAttribute("class", "span6"))
                .AppendText("None, nothing, nadia");
            }
            else
            {
                footerDiv.AppendComposite("div", new HtmlAttribute("class", "span6"))
                .AppendText(string.Format("Showing {0:N0} to {1:N0} of {2:N0}", result.FirstRecordOrdinal, result.LastRecordOrdinal, result.RecordCount));
            }


            HtmlComposite pagingList = footerDiv.AppendComposite("div", new HtmlAttribute("class", "span6"))
                                       .AppendComposite("div", new HtmlAttribute("class", "pull-right"))
                                       .AppendComposite("ul", new HtmlAttribute("class", "pagination"));


            pagingList
            .AppendComposite("li", new HtmlAttribute("class", result.PageCount > 1 && result.PageOrdinal > 0 ? "" : "disabled"))
            .AppendSimple("a", "«",
                          new HtmlAttribute("href", "javascript:void(0)"),
                          new HtmlAttribute("onclick", "EixoX.pageGrid(this,'0')"));

            pagingList
            .AppendComposite("li", new HtmlAttribute("class", result.PageCount > 1 && result.PageOrdinal > 0 ? "" : "disabled"))
            .AppendSimple("a", "<",
                          new HtmlAttribute("href", "javascript:void(0)"),
                          new HtmlAttribute("onclick", string.Concat("EixoX.pageGrid(this,'", result.PageOrdinal - 1, "')")));

            pagingList
            .AppendComposite("li")
            .AppendComposite(
                "button",
                new HtmlAttribute("class", "btn btn-default"),
                new HtmlAttribute("type", "submit"))
            .AppendText("pages: " + result.PageCount);

            pagingList
            .AppendComposite("li", new HtmlAttribute("class", result.PageCount > 1 && result.PageOrdinal < (result.PageCount - 1) ? "" : "disabled"))
            .AppendSimple("a", ">",
                          new HtmlAttribute("href", "javascript:void(0)"),
                          new HtmlAttribute("onclick", string.Concat("EixoX.pageGrid(this,'", result.PageOrdinal + 1, "')")));

            pagingList
            .AppendComposite("li", new HtmlAttribute("class", result.PageCount > 1 && result.PageOrdinal < (result.PageCount - 1) ? "" : "disabled"))
            .AppendSimple("a", "»",
                          new HtmlAttribute("href", "javascript:void(0)"),
                          new HtmlAttribute("onclick", string.Concat("EixoX.pageGrid(this,'", result.PageCount - 1, "')")));

            return(footer);
        }
示例#8
0
        protected override HtmlNode CreateInput(UI.UIControlState state)
        {
            HtmlComposite select = new HtmlComposite("select",
                                                     new HtmlAttribute("id", state.Name),
                                                     new HtmlAttribute("name", state.Name),
                                                     new HtmlAttribute("class", "form-control"));

            if (state.Options != null)
            {
                foreach (KeyValuePair <object, object> item in state.Options)
                {
                    HtmlSimple option = new HtmlSimple("option", item.Value);
                    option.Attributes.AddLast(new HtmlAttribute("value", item.Key));

                    if (item.Key.ToString().Equals(state.Value.ToString()))
                    {
                        option.Attributes.AddLast("selected", "selected");
                    }

                    select.Children.AddLast(option);
                }
            }

            return(select);
        }
 public static HtmlComposite AppendText(this HtmlComposite element, string text)
 {
     if (!string.IsNullOrEmpty(text))
     {
         element.Children.AddLast(new HtmlText(text));
     }
     return(element);
 }
 public static HtmlComposite AppendText(this HtmlComposite element, object value)
 {
     if (value != null)
     {
         element.Children.AddLast(new HtmlText(value.ToString()));
     }
     return(element);
 }
        public static void AppendHtmlOption(this HtmlComposite composite, object value, string text, bool selected)
        {
            HtmlSimple option = new HtmlSimple("option", text,
                                               new HtmlAttribute("value", value));

            if (selected)
            {
                option.Attributes.AddLast("selected", "selected");
            }

            composite.Children.AddLast(option);
        }
 public static HtmlComposite AppendText(this HtmlComposite element, string formatString, object value)
 {
     if (value != null)
     {
         element.Children.AddLast(new HtmlText(
                                      string.IsNullOrEmpty(formatString) ?
                                      value.ToString() :
                                      string.Format(formatString, value)
                                      ));
     }
     return(element);
 }
 private void AppendUnrelatedFilters(HtmlComposite composite, Aspect aspect, NameValueCollection parameters)
 {
     foreach (string key in parameters.AllKeys)
     {
         if (
             !"orderBy".Equals(key, StringComparison.OrdinalIgnoreCase) &&
             !"orderByDirection".Equals(key, StringComparison.OrdinalIgnoreCase) &&
             !"page".Equals(key, StringComparison.OrdinalIgnoreCase) &&
             !"pageSize".Equals(StringComparison.OrdinalIgnoreCase) &&
             !aspect.HasMember(key))
         {
             composite.AppendStandalone("input",
                                        new HtmlAttribute("type", "hidden"),
                                        new HtmlAttribute("name", key),
                                        new HtmlAttribute("value", parameters[key]));
         }
     }
 }
示例#14
0
        protected override HtmlNode CreateInput(UI.UIControlState state)
        {
            HtmlComposite select = new HtmlComposite("select",
                new HtmlAttribute("id", state.Name),
                new HtmlAttribute("name", state.Name));

            foreach (KeyValuePair<object, object> item in state.Options)
            {
                HtmlSimple option = new HtmlSimple("option", item.Value);
                option.Attributes.AddLast(new HtmlAttribute("value", item.Key));

                if (item.Key == state.Value)
                    option.Attributes.AddLast("selected", "selected");

                select.Children.AddLast(option);
            }

            return select;
        }
        protected override HtmlNode CreateInput(UI.UIControlState state)
        {
            HtmlComposite select = new HtmlComposite("select",
                                                     new HtmlAttribute("id", state.Name),
                                                     new HtmlAttribute("name", state.Name));

            foreach (KeyValuePair <object, object> item in state.Options)
            {
                HtmlSimple option = new HtmlSimple("option", item.Value);
                option.Attributes.AddLast(new HtmlAttribute("value", item.Key));

                if (item.Key == state.Value)
                {
                    option.Attributes.AddLast("selected", "selected");
                }

                select.Children.AddLast(option);
            }

            return(select);
        }
        public HtmlComposite Execute <T>(ClassSelect <T> select, NameValueCollection parameters)
        {
            ClassSelectResult <T> result = ExecuteSelect <T>(select);

            HtmlComposite form = new HtmlComposite(
                "form",
                new HtmlAttribute("method", "get"));

            form.AppendStandalone("input",
                                  new HtmlAttribute("type", "hidden"),
                                  new HtmlAttribute("name", "orderBy"),
                                  new HtmlAttribute("value", this.OrderBy));

            form.AppendStandalone("input",
                                  new HtmlAttribute("type", "hidden"),
                                  new HtmlAttribute("name", "orderByDirection"),
                                  new HtmlAttribute("value", this.OrderByDirection));

            form.AppendStandalone("input",
                                  new HtmlAttribute("type", "hidden"),
                                  new HtmlAttribute("name", "page"),
                                  new HtmlAttribute("value", "0"));

            if (parameters != null)
            {
                AppendUnrelatedFilters(form, select.Aspect, parameters);
            }

            HtmlComposite table = form.AppendComposite(
                "table",
                new HtmlAttribute("class", "table table-condensed table-striped table-bordered table-hover")
                );

            table.Children.AddLast(BuildTableHeader <T>());
            table.Children.AddLast(BuildTableBody <T>(result));
            table.Children.AddLast(BuildTableFooter <T>(result));

            return(form);
        }
 public static HtmlComposite AppendStandalone(this HtmlComposite element, string tagName, params HtmlAttribute[] attributes)
 {
     element.Children.AddLast(new HtmlStandalone(tagName, attributes));
     return(element);
 }
        public void RenderPagination(TextWriter writer)
        {
            HtmlComposite coldiv = new HtmlComposite("div", new HtmlAttribute("class", "col-xs-6"));

            coldiv.AppendStandalone(
                "input",
                new HtmlAttribute("type", "hidden"),
                new HtmlAttribute("name", _PageOrdinal.Key),
                new HtmlAttribute("id", _PageOrdinal.Key),
                new HtmlAttribute("value", Result.PageOrdinal));


            HtmlComposite paginationUl = coldiv.AppendComposite(
                "ul",
                new HtmlAttribute("class", "pagination pull-right"));

            paginationUl.AppendComposite(
                "li",
                new HtmlAttribute("class", ""))
            .AppendSimple(
                "a",
                "First",
                new HtmlAttribute("id", "firstPage"),
                new HtmlAttribute("href", "#"));

            //Previous page button
            paginationUl.AppendComposite(
                "li",
                new HtmlAttribute("class", Result.HasPreviousPages ? "" : "disabled"))
            .AppendSimple(
                "a",
                "Previous",
                new HtmlAttribute("id", "previousPage"),
                Result.HasPreviousPages ? new HtmlAttribute("href", "#") : new HtmlAttribute());

            //Records found
            paginationUl.AppendComposite(
                "li",
                new HtmlAttribute("class", ""))
            .AppendSimple(
                "a",
                Result.RecordCount + " records. Page " + (Result.PageOrdinal + 1) + " of " + Result.PageCount,
                new HtmlAttribute());

            //Next page button
            paginationUl.AppendComposite(
                "li",
                new HtmlAttribute("class", Result.HasMorePages ? "" : "disabled"))
            .AppendSimple(
                "a",
                "Next",
                new HtmlAttribute("id", "nextPage"),
                Result.HasMorePages ? new HtmlAttribute("href", "#") : new HtmlAttribute());

            //Last page button
            paginationUl.AppendComposite(
                "li",
                new HtmlAttribute("class", Result.HasMorePages ? "" : "disabled"))
            .AppendSimple(
                "a",
                "Last",
                new HtmlAttribute("id", "lastPage"),
                Result.HasMorePages ? new HtmlAttribute("href", "#") : new HtmlAttribute());

            coldiv.Write(writer);
        }
        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);
        }
        private HtmlComposite BuildTableHeader <T>()
        {
            HtmlComposite thead = new HtmlComposite("thead");

            HtmlComposite thead_tr = thead.AppendComposite("tr");

            foreach (BootstrapQueryHelperColumn col in this.columns)
            {
                HtmlComposite th  = thead_tr.AppendComposite("th");
                HtmlComposite tha = th.AppendComposite("a");

                tha.AppendText(col.Caption + "   ");
                tha.AppendAttribute("href", "javascript:void(0)");

                if (col.Name.Equals(this.OrderBy, StringComparison.OrdinalIgnoreCase))
                {
                    if (this.OrderByDirection == EixoX.Data.SortDirection.Ascending)
                    {
                        tha.AppendSimple(
                            "span",
                            "",
                            new HtmlAttribute("class", "fa fa-sort-asc"));


                        tha.AppendAttribute("onclick", string.Concat("EixoX.sortGrid(this,'", col.Name, "','", EixoX.Data.SortDirection.Descending, "')"));
                    }
                    else
                    {
                        tha.AppendSimple(
                            "span",
                            "",
                            new HtmlAttribute("class", "fa fa-sort-desc"));

                        tha.AppendAttribute("onclick", string.Concat("EixoX.sortGrid(this,'", col.Name, "','", EixoX.Data.SortDirection.Ascending, "')"));
                    }
                }
                else
                {
                    tha.AppendSimple(
                        "span",
                        "",
                        new HtmlAttribute("class", "fa fa-sort"));

                    tha.AppendAttribute("onclick", string.Concat("EixoX.sortGrid(this,'", col.Name, "','", EixoX.Data.SortDirection.Ascending, "')"));
                }
            }

            HtmlComposite tr2 = thead.AppendComposite("tr");

            foreach (BootstrapQueryHelperColumn col in this.columns)
            {
                HtmlComposite th2 = tr2.AppendComposite(
                    "td",
                    new HtmlAttribute("style", "padding:0px")
                    );

                th2.AppendStandalone(
                    "input",
                    new HtmlAttribute("type", "text"),
                    new HtmlAttribute("placeholder", "filtrar"),
                    new HtmlAttribute("name", col.Name),
                    new HtmlAttribute("value", col.Filter),
                    new HtmlAttribute("style", "margin:0px; border-radius:0px; display:block; width:94%; border:none;"));
            }

            return(thead);
        }
 public static HtmlComposite AppendSimple(this HtmlComposite element, string tagName, object content, params HtmlAttribute[] attributes)
 {
     element.Children.AddLast(new HtmlSimple(tagName, content, attributes));
     return(element);
 }
        public void RenderOrderBy(TextWriter writer)
        {
            HtmlComposite coldiv = new HtmlComposite("div", new HtmlAttribute("style", "display:none"));

            coldiv.AppendSimple(
                "label",
                "Order by",
                new HtmlAttribute("class", "control-label"));
            coldiv.Write(writer);


            coldiv = new HtmlComposite("div", new HtmlAttribute("style", "display:none"));
            HtmlComposite selectOrderBy = coldiv.AppendComposite(
                "select",
                new HtmlAttribute("name", _OrderBy.Key),
                new HtmlAttribute("id", _OrderBy.Key),
                new HtmlAttribute("class", "changeReload"));

            EixoX.Data.DatabaseAspect <T> aspect = EixoX.Data.DatabaseAspect <T> .Instance;
            for (int i = 0; i < aspect.Count; i++)
            {
                selectOrderBy.AppendHtmlOption(i, aspect[i].Name, i == _OrderBy.Value);
            }

            coldiv.Write(writer);


            coldiv = new HtmlComposite("div", new HtmlAttribute("style", "display:none"));
            HtmlComposite selectDirection = coldiv.AppendComposite(
                "select",
                new HtmlAttribute("name", _SortDirection.Key),
                new HtmlAttribute("id", _SortDirection.Key),
                new HtmlAttribute("class", "input-small  changeReload"));

            if (_SortDirection.Value == EixoX.Data.SortDirection.Ascending)
            {
                selectDirection.AppendSimple(
                    "option",
                    EixoX.Data.SortDirection.Ascending,
                    new HtmlAttribute("value", EixoX.Data.SortDirection.Ascending),
                    new HtmlAttribute("selected", "selected"));

                selectDirection.AppendSimple(
                    "option",
                    EixoX.Data.SortDirection.Descending,
                    new HtmlAttribute("value", EixoX.Data.SortDirection.Descending));
            }
            else
            {
                selectDirection.AppendSimple(
                    "option",
                    EixoX.Data.SortDirection.Ascending,
                    new HtmlAttribute("value", EixoX.Data.SortDirection.Ascending));

                selectDirection.AppendSimple(
                    "option",
                    EixoX.Data.SortDirection.Descending,
                    new HtmlAttribute("value", EixoX.Data.SortDirection.Descending),
                    new HtmlAttribute("selected", "selected"));
            }

            coldiv.Write(writer);
        }