当前位置: 首页>>代码示例>>C#>>正文


C# IHtmlWriter.AddKnockoutForeachDataBind方法代码示例

本文整理汇总了C#中IHtmlWriter.AddKnockoutForeachDataBind方法的典型用法代码示例。如果您正苦于以下问题:C# IHtmlWriter.AddKnockoutForeachDataBind方法的具体用法?C# IHtmlWriter.AddKnockoutForeachDataBind怎么用?C# IHtmlWriter.AddKnockoutForeachDataBind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IHtmlWriter的用法示例。


在下文中一共展示了IHtmlWriter.AddKnockoutForeachDataBind方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderContents

        protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            // render the header
            head?.Render(writer, context);

            // render body
            if (!RenderOnServer)
            {
                writer.AddKnockoutForeachDataBind("dotvvm.evaluator.getDataSourceItems($gridViewDataSet)");
            }
            writer.RenderBeginTag("tbody");

            // render contents
            if (RenderOnServer)
            {
                // render on server
                var index = 0;
                foreach (var child in Children.Except(new[] { head, emptyDataContainer }))
                {
                    child.Render(writer, context);
                    index++;
                }
            }
            else
            {
                // render on client
                if (InlineEditing)
                {
                    var placeholder = new DataItemContainer { DataContext = null };
                    placeholder.SetValue(Internal.PathFragmentProperty, JavascriptCompilationHelper.AddIndexerToViewModel(GetPathFragmentExpression(), "$index"));
                    placeholder.SetValue(Internal.ClientIDFragmentProperty, "$index()");
                    writer.WriteKnockoutDataBindComment("if", "ko.unwrap(ko.unwrap($gridViewDataSet).EditRowId) !== ko.unwrap($data[ko.unwrap(ko.unwrap($gridViewDataSet).PrimaryKeyPropertyName)])");
                    CreateTemplates(context, placeholder);
                    Children.Add(placeholder);
                    placeholder.Render(writer, context);
                    writer.WriteKnockoutDataBindEndComment();

                    var placeholderEdit = new DataItemContainer { DataContext = null };
                    placeholderEdit.SetValue(Internal.PathFragmentProperty, JavascriptCompilationHelper.AddIndexerToViewModel(GetPathFragmentExpression(), "$index"));
                    placeholderEdit.SetValue(Internal.ClientIDFragmentProperty, "$index()");
                    writer.WriteKnockoutDataBindComment("if", "ko.unwrap(ko.unwrap($gridViewDataSet).EditRowId) === ko.unwrap($data[ko.unwrap(ko.unwrap($gridViewDataSet).PrimaryKeyPropertyName)])");
                    CreateTemplates(context, placeholderEdit, true);
                    Children.Add(placeholderEdit);
                    placeholderEdit.Render(writer, context);
                    writer.WriteKnockoutDataBindEndComment();
                }
                else
                {
                    var placeholder = new DataItemContainer { DataContext = null };
                    placeholder.SetValue(Internal.PathFragmentProperty, JavascriptCompilationHelper.AddIndexerToViewModel(GetPathFragmentExpression(), "$index"));
                    placeholder.SetValue(Internal.ClientIDFragmentProperty, "$index()");
                    CreateRowWithCells(context, placeholder);
                    Children.Add(placeholder);
                    placeholder.Render(writer, context);

                }
            }

            writer.RenderEndTag();
        }
开发者ID:darilek,项目名称:dotvvm,代码行数:60,代码来源:GridView.cs

示例2: RenderBeginTag

        protected override void RenderBeginTag(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            TagName = WrapperTagName;

            if (!RenderOnServer)
            {
                var javascriptDataSourceExpression = GetForeachDataBindJavascriptExpression();

                if (RenderWrapperTag)
                {
                    writer.AddKnockoutForeachDataBind(javascriptDataSourceExpression);
                }
                else
                {
                    writer.WriteKnockoutForeachComment(javascriptDataSourceExpression);
                }
            }

            if (RenderWrapperTag)
            {
                base.RenderBeginTag(writer, context);
            }
        }
开发者ID:darilek,项目名称:dotvvm,代码行数:23,代码来源:Repeater.cs

示例3: AddAttributesToRender

        /// <summary>
        /// Adds all attributes that should be added to the control begin tag.
        /// </summary>
        protected override void AddAttributesToRender(IHtmlWriter writer, RenderContext context)
        {
            TagName = WrapperTagName;

            if (!RenderOnServer)
            {
                writer.AddKnockoutForeachDataBind(GetDataSourceBinding().TranslateToClientScript(this, DataSourceProperty));
            }

            base.AddAttributesToRender(writer, context);
        }
开发者ID:adamjez,项目名称:dotvvm,代码行数:14,代码来源:Repeater.cs

示例4: RenderContents

        protected override void RenderContents(IHtmlWriter writer, RenderContext context)
        {
            if (Children.Count == 0) return;

            // render the header
            Children[0].Render(writer, context);

            // render body
            var dataSourceBinding = GetDataSourceBinding();
            if (!RenderOnServer)
            {
                var expression = dataSourceBinding.TranslateToClientScript(this, DataSourceProperty);
                writer.AddKnockoutForeachDataBind(expression);
            }
            writer.RenderBeginTag("tbody");

            // render contents
            if (RenderOnServer)
            {
                // render on server
                var index = 0;
                foreach (var child in Children.Skip(1))
                {
                    context.PathFragments.Push(dataSourceBinding.GetViewModelPathExpression(this, DataSourceProperty) + "[" + index + "]");
                    Children[index].Render(writer, context);
                    context.PathFragments.Pop();
                    index++;
                }
            }
            else
            {
                // render on client
                for (var i = Children.Count - 1; i > 0; i--)
                {
                    Children.RemoveAt(i);
                }

                var placeholder = new DataItemContainer();
                placeholder.SetValue(Internal.IsDataContextBoundaryProperty, true);
                Children.Add(placeholder);
                CreateRow(context.RequestContext, placeholder);

                context.PathFragments.Push(dataSourceBinding.GetViewModelPathExpression(this, DataSourceProperty) + "[$index]");
                placeholder.Render(writer, context);
                context.PathFragments.Pop();
            }

            writer.RenderEndTag();
        }
开发者ID:adamjez,项目名称:dotvvm,代码行数:49,代码来源:GridView.cs

示例5: RenderContents

        protected override void RenderContents(IHtmlWriter writer, RenderContext context)
        {
            if (Children.Count == 0) return;

            // render the header
            Children[0].Render(writer, context);

            // render body
            var dataSourceBinding = GetDataSourceBinding();
            if (!RenderOnServer)
            {
                var expression = dataSourceBinding.GetKnockoutBindingExpression();
                writer.AddKnockoutForeachDataBind(expression);
            }
            writer.RenderBeginTag("tbody");

            // render contents
            if (RenderOnServer)
            {
                // render on server
                var index = 0;
                foreach (var child in Children.Skip(1))
                {
                    Children[index].Render(writer, context);
                    index++;
                }
            }
            else
            {
                // render on client
                var placeholder = new DataItemContainer { DataContext = null };
                placeholder.SetValue(Internal.PathFragmentProperty, 
                    JavascriptCompilationHelper.AddIndexerToViewModel(dataSourceBinding.GetKnockoutBindingExpression(), "$index"));
                Children.Add(placeholder);

                CreateRow(context.RequestContext, placeholder);

                placeholder.Render(writer, context);
            }

            writer.RenderEndTag();
        }
开发者ID:holajan,项目名称:dotvvm,代码行数:42,代码来源:GridView.cs

示例6: AddAttributesToRender

        /// <summary>
        /// Adds all attributes that should be added to the control begin tag.
        /// </summary>
        protected override void AddAttributesToRender(IHtmlWriter writer, RenderContext context)
        {
            TagName = WrapperTagName;

            if (!RenderOnServer)
            {
                writer.AddKnockoutForeachDataBind(GetDataSourceBinding().GetKnockoutBindingExpression());
            }

            base.AddAttributesToRender(writer, context);
        }
开发者ID:holajan,项目名称:dotvvm,代码行数:14,代码来源:Repeater.cs


注:本文中的IHtmlWriter.AddKnockoutForeachDataBind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。