gpt4 book ai didi

c# - 在 asp.net 中使用默认属性创建剑道网格

转载 作者:太空宇宙 更新时间:2023-11-03 22:52:26 25 4
gpt4 key购买 nike

我使用 kendo ASP.NET MVC,并且经常使用 kendo 网格。大多数时候我设置相同的属性,例如使用自定义消息过滤、分组、分页等。我想知道是否有办法在某处设置此默认设置或为一些类似的剑道网格创建某种包装器。

最佳答案

我已经为网格、下拉菜单和日期选择器制作了多个 Html 扩展,并且通过这种方式清理了我的 html。此外,我还插入了语言设置和全局事件。我给你一个我的一般搜索结果网格的例子作为指导。

public static Kendo.Mvc.UI.Fluent.GridBuilder<T> SearchConfigGrid<T>(this HtmlHelper helper)
where T : class
{
var gcw = "GridCommandWord";
return helper.Kendo().Grid<T>()
.Navigatable()
.Scrollable(s => s.Enabled(true).Height("auto"))
.HtmlAttributes(new { @class = "hide-vertical-scrollbar"})
.NoRecords(_resources.GetResource(gcw, "NoRecordsFound"))
.Groupable(groupable => groupable.Messages(m => m.Empty(_resources.GetResource(gcw, "GroupableMessage"))))
.Sortable(sortable => sortable
.SortMode(GridSortMode.MultipleColumn))
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.StartsWith(_resources.GetResource(gcw, "StartsWith"))
.Contains(_resources.GetResource(gcw, "Contains"))
.IsEqualTo(_resources.GetResource(gcw, "IsEqualTo"))
.IsNotEqualTo(_resources.GetResource(gcw, "IsNotEqualTo")))
.ForDate(dt => dt.Clear()
.IsGreaterThan(_resources.GetResource(gcw, "IsGreaterThan"))
.IsGreaterThanOrEqualTo(_resources.GetResource(gcw, "IsGreaterThanOrEqualTo"))
.IsLessThan(_resources.GetResource(gcw, "IsLessThan"))
.IsLessThanOrEqualTo(_resources.GetResource(gcw, "IsLessThanOrEqualTo")))
.ForNumber(dt => dt.Clear()
.IsEqualTo(_resources.GetResource(gcw, "IsEqualTo"))
.IsNotEqualTo(_resources.GetResource(gcw, "IsNotEqualTo"))
.IsGreaterThan(_resources.GetResource(gcw, "IsGreaterThan"))
.IsGreaterThanOrEqualTo(_resources.GetResource(gcw, "IsGreaterThanOrEqualTo"))
.IsLessThan(_resources.GetResource(gcw, "IsLessThan"))
.IsLessThanOrEqualTo(_resources.GetResource(gcw, "IsLessThanOrEqualTo"))))
.Messages(m => m.Info(_resources.GetResource(gcw, "Info"))
.And(_resources.GetResource(gcw, "And"))
.Or(_resources.GetResource(gcw, "Or"))
.Clear(_resources.GetResource(gcw, "Clear"))
.Filter(_resources.GetResource(gcw, "Filter"))
.CheckAll(_resources.GetResource(gcw, "CheckAll"))
.IsFalse("&nbsp;" + _resources.GetResource(gcw, "No"))
.IsTrue("&nbsp;" + _resources.GetResource(gcw, "Yes") + "&nbsp;&nbsp;&nbsp;")
.Info(_resources.GetResource(gcw, "ShowRecords"))
.SelectedItemsFormat(_resources.GetResource(gcw, "SelectedItemsFormat"))))
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5)
.Messages(m => m
.Display(_resources.GetResource(gcw, "Display"))
.ItemsPerPage(_resources.GetResource(gcw, "ItemsPerPage"))
.Empty(_resources.GetResource(gcw, "Empty"))
.Page(_resources.GetResource(gcw, "Page"))
.Of(_resources.GetResource(gcw, "Of"))
.First(_resources.GetResource(gcw, "First"))
.Previous(_resources.GetResource(gcw, "Previous"))
.Next(_resources.GetResource(gcw, "Next"))
.Last(_resources.GetResource(gcw, "Last"))
.Refresh(_resources.GetResource(gcw, "Refresh"))
.MorePages(_resources.GetResource(gcw, "MorePages"))));
}

关于c# - 在 asp.net 中使用默认属性创建剑道网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46854379/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com