gpt4 book ai didi

c# - Kendo UI Grid- - 默认排序日期 Asc

转载 作者:太空狗 更新时间:2023-10-29 19:59:39 25 4
gpt4 key购买 nike

我正在使用 kendo UI,并希望默认按日期升序对我的网格进行排序,但不知道如何修改它。我的理解是它是数据源部分的一部分:

@(Html.Kendo().Grid<CustomerAnimalViewModel>()
.Name(gridId)
.HtmlAttributes(new { @class = "grid" })
.Columns(columns =>
{
columns.Bound(c => c.AnimalId).Visible(false);
columns.Bound(c => c.RegistrationNumber).ClientTemplate("<a class='active' href=javascript:viewAnimal(\"" + "#: AnimalId #" + "\",\"" + "#=escape(Name) #" + "\") >#: RegistrationNumber #</a>");
columns.Bound(c => c.Type);
columns.Bound(c => c.Prefix);
columns.Bound(c => c.Name);
columns.Bound(c => c.DateOfBirth).ClientTemplate("#= kendo.toString(DateOfBirth == null ? '' : DateOfBirth, '" + Constants.DateFormat + "') #");
columns.Bound(c => c.Sex);
columns.Bound(c => c.HMC);
columns.Bound(c => c.Usability).Visible(false);
columns.Bound(c => c.Status);
columns.Command(command => { command.Destroy(); }).Title(Resources.Actions);
})
.DataSource(dataSource => dataSource
.Ajax()

.Model(model =>
{
model.Id(p => p.AnimalId);
model.Field(p => p.RegistrationNumber);
model.Field(p => p.Type);
model.Field(p => p.Prefix);
model.Field(p => p.Name);
model.Field(p => p.Status);
model.Field(p => p.Sex);
model.Field(p => p.HMC);
model.Field(p => p.Usability);
model.Field(p => p.Status);
})
.Read(read => read.Action("ReadTypes", "Customer").Data("filterData"))
.Destroy(destroy => destroy.Action("DeleteAnimal", "Customer"))
)
.Navigatable()
.Sortable()
.Filterable()
.Pageable()

)

最佳答案

dataSource 中添加 .Sort(x=>x.Add("DateOfBirth").Ascending())

@(Html.Kendo().Grid<CustomerAnimalViewModel>()
.Name(gridId)
.HtmlAttributes(new { @class = "grid" })
.Columns(columns =>
{
columns.Bound(c => c.AnimalId).Visible(false);
columns.Bound(c => c.RegistrationNumber).ClientTemplate("<a class='active' href=javascript:viewAnimal(\"" + "#: AnimalId #" + "\",\"" + "#=escape(Name) #" + "\") >#: RegistrationNumber #</a>");
columns.Bound(c => c.Type);
columns.Bound(c => c.Prefix);
columns.Bound(c => c.Name);
columns.Bound(c => c.DateOfBirth).ClientTemplate("#= kendo.toString(DateOfBirth == null ? '' : DateOfBirth, '" + Constants.DateFormat + "') #");
columns.Bound(c => c.Sex);
columns.Bound(c => c.HMC);
columns.Bound(c => c.Usability).Visible(false);
columns.Bound(c => c.Status);
columns.Command(command => { command.Destroy(); }).Title(Resources.Actions);
})
.DataSource(dataSource => dataSource
.Ajax()
.Sort(x=>x.Add("DateOfBirth").Ascending())
.Model(model =>
{
model.Id(p => p.AnimalId);
model.Field(p => p.RegistrationNumber);
model.Field(p => p.Type);
model.Field(p => p.Prefix);
model.Field(p => p.Name);
model.Field(p => p.Status);
model.Field(p => p.Sex);
model.Field(p => p.HMC);
model.Field(p => p.Usability);
model.Field(p => p.Status);
})
.Read(read => read.Action("ReadTypes", "Customer").Data("filterData"))
.Destroy(destroy => destroy.Action("DeleteAnimal", "Customer"))
)
.Navigatable()
.Sortable()
.Filterable()
.Pageable()

)

关于c# - Kendo UI Grid- - 默认排序日期 Asc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25045822/

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