本文整理汇总了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();
}
示例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);
}
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}