Пример #1
0
        public override void CreateControls(DotvvmRequestContext context, DotvvmControl container)
        {
            var literal = new Literal();
            literal.FormatString = FormatString;
            literal.SetBinding(Literal.TextProperty, GetValueBinding(ValueBindingProperty));

            container.Children.Add(literal);
        }
Пример #2
0
        public override void CreateControls(IDotvvmRequestContext context, DotvvmControl container)
        {
            var literal = new Literal();

            literal.FormatString = FormatString;
            literal.SetBinding(Literal.TextProperty, GetValueBinding(ValueBindingProperty));

            container.Children.Add(literal);
        }
Пример #3
0
        protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            writer.AddKnockoutDataBind("css", "{ 'disabled': IsFirstPage() }");
            firstLi.Render(writer, context);

            writer.AddKnockoutDataBind("css", "{ 'disabled': IsFirstPage() }");
            previousLi.Render(writer, context);

            // render template
            writer.WriteKnockoutForeachComment("NearPageIndexes");

            // render page number
            numbersPlaceHolder.Children.Clear();
            HtmlGenericControl li;

            if (!RenderLinkForCurrentPage)
            {
                writer.AddKnockoutDataBind("visible", "$data == $parent.PageIndex()");
                writer.AddKnockoutDataBind("css", "{'active': $data == $parent.PageIndex()}");
                li = new HtmlGenericControl("li");
                var literal = new Literal();
                literal.DataContext = 0;
                literal.SetBinding(Literal.TextProperty, new ValueBindingExpression(vm => ((int)vm[0] + 1).ToString(), "$data + 1"));
                li.Children.Add(literal);
                numbersPlaceHolder.Children.Add(li);
                li.Render(writer, context);

                writer.AddKnockoutDataBind("visible", "$data != $parent.PageIndex()");
            }
            writer.AddKnockoutDataBind("css", "{ 'active': $data == $parent.PageIndex()}");
            li = new HtmlGenericControl("li");
            li.SetValue(Internal.PathFragmentProperty, "NearPageIndexes[$index]");
            var link = new LinkButton();

            li.Children.Add(link);
            link.SetBinding(ButtonBase.TextProperty, new ValueBindingExpression(vm => ((int)vm[0] + 1).ToString(), "$data + 1"));
            link.SetBinding(ButtonBase.ClickProperty, GoToThisPageCommand);
            object enabledValue = HasValueBinding(EnabledProperty) ? (object)new ValueBindingExpression(h => GetValueBinding(EnabledProperty).Evaluate(this, EnabledProperty), "$pagerEnabled") : Enabled;

            if (!true.Equals(enabledValue))
            {
                link.SetValue(LinkButton.EnabledProperty, enabledValue);
            }
            numbersPlaceHolder.Children.Add(li);
            li.Render(writer, context);

            writer.WriteKnockoutDataBindEndComment();

            writer.AddKnockoutDataBind("css", "{ 'disabled': IsLastPage() }");
            nextLi.Render(writer, context);

            writer.AddKnockoutDataBind("css", "{ 'disabled': IsLastPage() }");
            lastLi.Render(writer, context);
        }
Пример #4
0
        public override void CreateControls(IDotvvmRequestContext context, DotvvmControl container)
        {
            var literal = new Literal();

            literal.FormatString = FormatString;
            #pragma warning disable
            literal.ValueType = ValueType;
            #pragma warning restore
            literal.SetBinding(Literal.TextProperty, ValueBinding);
            Validator.Place(literal, container.Children, ValueBinding, ValidatorPlacement);
            container.Children.Add(literal);
        }
Пример #5
0
        protected virtual HtmlGenericControl CreatePageNumberButton(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            HtmlGenericControl li;
            var currentPageTextContext = DataContextStack.Create(typeof(int), NumberButtonsPlaceHolder.GetDataContextType());
            var currentPageTextBinding = ValueBindingExpression.CreateBinding(bindingService.WithoutInitialization(),
                                                                              vm => ((int)vm[0] + 1).ToString(),
                                                                              currentPageTextJs,
                                                                              currentPageTextContext);

            if (!RenderLinkForCurrentPage)
            {
                writer.AddKnockoutDataBind("visible", "$data == $parent.PagingOptions().PageIndex()");
                AddItemCssClass(writer, context);
                AddKnockoutActiveCssDataBind(writer, context, "$data == $parent.PagingOptions().PageIndex()");
                li = new HtmlGenericControl("li");
                var literal = new Literal();
                literal.DataContext = 0;
                literal.SetDataContextType(currentPageTextContext);

                literal.SetBinding(Literal.TextProperty, currentPageTextBinding);
                li.Children.Add(literal);
                NumberButtonsPlaceHolder.Children.Add(li);
                li.Render(writer, context);

                writer.AddKnockoutDataBind("visible", "$data != $parent.PagingOptions().PageIndex()");
            }

            AddItemCssClass(writer, context);
            AddKnockoutActiveCssDataBind(writer, context, "$data == $parent.PagingOptions().PageIndex()");
            li = new HtmlGenericControl("li");
            li.SetValue(Internal.PathFragmentProperty, "PagingOptions.NearPageIndexes[$index]");
            var link = new LinkButton();

            li.Children.Add(link);
            link.SetDataContextType(currentPageTextContext);
            link.SetBinding(ButtonBase.TextProperty, currentPageTextBinding);
            link.SetBinding(ButtonBase.ClickProperty, commonBindings.GoToThisPageCommand);
            object enabledValue = HasValueBinding(EnabledProperty)
                ? (object)ValueBindingExpression.CreateBinding(bindingService.WithoutInitialization(),
                                                               h => GetValueBinding(EnabledProperty).Evaluate(this),
                                                               new JsSymbolicParameter(JavascriptTranslator.KnockoutContextParameter).Member("$pagerEnabled"))
                : Enabled;

            if (!true.Equals(enabledValue))
            {
                link.SetValue(LinkButton.EnabledProperty, enabledValue);
            }
            NumberButtonsPlaceHolder.Children.Add(li);
            return(li);
        }
Пример #6
0
        protected internal override void OnPreRender(IDotvvmRequestContext context)
        {
            if ((HasBinding(TextProperty) || !string.IsNullOrEmpty(Text)) && !HasOnlyWhiteSpaceContent())
            {
                throw new DotvvmControlException(this, "Text property and inner content of the <dot:Button> control cannot be set at the same time!");
            }

            if (ButtonTagName == ButtonTagName.button && HasValueBinding(TextProperty))
            {
                var literal = new Literal {
                    RenderSpanElement = false
                };
                literal.SetBinding(c => c.Text, GetBinding(TextProperty));
                Children.Add(literal);
            }

            base.OnPreRender(context);
        }
Пример #7
0
        protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            writer.AddKnockoutDataBind("css", "{ 'disabled': PagingOptions().IsFirstPage() }");
            firstLi.Render(writer, context);

            writer.AddKnockoutDataBind("css", "{ 'disabled': PagingOptions().IsFirstPage() }");
            previousLi.Render(writer, context);

            // render template
            writer.WriteKnockoutForeachComment("PagingOptions().NearPageIndexes");

            // render page number
            numbersPlaceHolder.Children.Clear();
            HtmlGenericControl li;
            var currentPageTextContext = DataContextStack.Create(typeof(int), numbersPlaceHolder.GetDataContextType());
            var currentPageTextBinding = ValueBindingExpression.CreateBinding(bindingService.WithoutInitialization(),
                                                                              vm => ((int)vm[0] + 1).ToString(),
                                                                              currentPageTextJs,
                                                                              currentPageTextContext);

            if (!RenderLinkForCurrentPage)
            {
                writer.AddKnockoutDataBind("visible", "$data == $parent.PagingOptions().PageIndex()");
                writer.AddKnockoutDataBind("css", "{'active': $data == $parent.PagingOptions().PageIndex()}");
                li = new HtmlGenericControl("li");
                var literal = new Literal();
                literal.DataContext = 0;
                literal.SetDataContextType(currentPageTextContext);

                literal.SetBinding(Literal.TextProperty, currentPageTextBinding);
                li.Children.Add(literal);
                numbersPlaceHolder.Children.Add(li);
                li.Render(writer, context);

                writer.AddKnockoutDataBind("visible", "$data != $parent.PagingOptions().PageIndex()");
            }
            writer.AddKnockoutDataBind("css", "{ 'active': $data == $parent.PagingOptions().PageIndex()}");
            li = new HtmlGenericControl("li");
            li.SetValue(Internal.PathFragmentProperty, "PagingOptions.NearPageIndexes[$index]");
            var link = new LinkButton();

            li.Children.Add(link);
            link.SetDataContextType(currentPageTextContext);
            link.SetBinding(ButtonBase.TextProperty, currentPageTextBinding);
            link.SetBinding(ButtonBase.ClickProperty, commonBindings.GoToThisPageCommand);
            object enabledValue = HasValueBinding(EnabledProperty) ?
                                  (object)ValueBindingExpression.CreateBinding(bindingService.WithoutInitialization(),
                                                                               h => GetValueBinding(EnabledProperty).Evaluate(this),
                                                                               new JsSymbolicParameter(JavascriptTranslator.KnockoutContextParameter).Member("$pagerEnabled")) :
                                  Enabled;

            if (!true.Equals(enabledValue))
            {
                link.SetValue(LinkButton.EnabledProperty, enabledValue);
            }
            numbersPlaceHolder.Children.Add(li);
            li.Render(writer, context);

            writer.WriteKnockoutDataBindEndComment();

            writer.AddKnockoutDataBind("css", "{ 'disabled': PagingOptions().IsLastPage() }");
            nextLi.Render(writer, context);

            writer.AddKnockoutDataBind("css", "{ 'disabled': PagingOptions().IsLastPage() }");
            lastLi.Render(writer, context);
        }
Пример #8
0
        protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            writer.AddKnockoutDataBind("css", "{ 'disabled': IsFirstPage() }");
            firstLi.Render(writer, context);

            writer.AddKnockoutDataBind("css", "{ 'disabled': IsFirstPage() }");
            previousLi.Render(writer, context);

            // render template
            writer.WriteKnockoutForeachComment("NearPageIndexes");
        
            // render page number
            numbersPlaceHolder.Children.Clear();
            HtmlGenericControl li;
            if (!RenderLinkForCurrentPage)
            {
                writer.AddKnockoutDataBind("visible", "$data == $parent.PageIndex()");
                writer.AddKnockoutDataBind("css", "{'active': $data == $parent.PageIndex()}");
                li = new HtmlGenericControl("li");
                var literal = new Literal();
                literal.DataContext = 0;
                literal.SetBinding(Literal.TextProperty, new ValueBindingExpression(vm => ((int)vm[0] + 1).ToString(), "$data + 1"));
                li.Children.Add(literal);
                numbersPlaceHolder.Children.Add(li);
                li.Render(writer, context);

                writer.AddKnockoutDataBind("visible", "$data != $parent.PageIndex()");
            }
            writer.AddKnockoutDataBind("css", "{ 'active': $data == $parent.PageIndex()}");
            li = new HtmlGenericControl("li");
            li.SetValue(Internal.PathFragmentProperty, "NearPageIndexes[$index]");
            var link = new LinkButton();
            li.Children.Add(link);
            link.SetBinding(ButtonBase.TextProperty, new ValueBindingExpression(vm => ((int)vm[0] + 1).ToString(), "$data + 1"));
            link.SetBinding(ButtonBase.ClickProperty, GoToThisPageCommand);
            object enabledValue = HasValueBinding(EnabledProperty) ? (object)new ValueBindingExpression(h => GetValueBinding(EnabledProperty).Evaluate(this, EnabledProperty), "$pagerEnabled") : Enabled;
            if (!true.Equals(enabledValue)) link.SetValue(LinkButton.EnabledProperty, enabledValue);
            numbersPlaceHolder.Children.Add(li);
            li.Render(writer, context);

            writer.WriteKnockoutDataBindEndComment();

            writer.AddKnockoutDataBind("css", "{ 'disabled': IsLastPage() }");
            nextLi.Render(writer, context);

            writer.AddKnockoutDataBind("css", "{ 'disabled': IsLastPage() }");
            lastLi.Render(writer, context);
        }
Пример #9
0
        protected override void RenderContents(IHtmlWriter writer, RenderContext context)
        {
            writer.AddKnockoutDataBind("css", "{ 'disabled': IsFirstPage() }");
            firstLi.Render(writer, context);

            writer.AddKnockoutDataBind("css", "{ 'disabled': IsFirstPage() }");
            previousLi.Render(writer, context);

            // render template
            writer.WriteKnockoutForeachComment("NearPageIndexes");

            // render page number
            numbersPlaceholder.Children.Clear();
            HtmlGenericControl li;
            if (!RenderLinkForCurrentPage)
            {
                writer.AddKnockoutDataBind("visible", "$data == $parent.PageIndex()");
                li = new HtmlGenericControl("li");
                var literal = new Literal();
                literal.SetBinding(Literal.TextProperty, new ValueBindingExpression(vm => (int)vm[0] + 1, "$data + 1"));
                li.Children.Add(literal);
                numbersPlaceholder.Children.Add(li);
                li.Render(writer, context);

                writer.AddKnockoutDataBind("visible", "$data != $parent.PageIndex()");
            }
            writer.AddKnockoutDataBind("css", "{ 'active': $data == $parent.PageIndex()}");
            li = new HtmlGenericControl("li");
            li.SetValue(Internal.PathFragmentProperty, "NearPageIndexes[$index]");
            var link = new LinkButton();
            li.Children.Add(link);
            link.SetBinding(ButtonBase.TextProperty, new ValueBindingExpression(vm => (int)vm[0] + 1, "$data + 1"));
            link.SetBinding(ButtonBase.ClickProperty, GoToThisPageCommand);
            numbersPlaceholder.Children.Add(li);
            li.Render(writer, context);

            writer.WriteKnockoutDataBindEndComment();

            writer.AddKnockoutDataBind("css", "{ 'disabled': IsLastPage() }");
            nextLi.Render(writer, context);

            writer.AddKnockoutDataBind("css", "{ 'disabled': IsLastPage() }");
            lastLi.Render(writer, context);
        }