【发布时间】:2015-11-29 14:06:13
【问题描述】:
在 asp.net mvc 页面中即时使用看起来像这样的 Telerik 网格
<div>
@(Html.Kendo().Grid<Project.Models.Bench>
()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.name).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
columns.Bound(p => p.seatsCount).Filterable(ftb => ftb.Cell(cell => cell.Operator("gte")));
columns.Bound(p => p.bookedSeats).Filterable(ftb => ftb.Cell(cell => cell.Operator("gte")));
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
//.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
//.ServerOperation(true)
.Read(read => read.Action("GetBenches", "home"))
)
)
</div>
这是我的板凳课:
public class Bench
{
public int id { get; set; }
public string name { get; set; }
public bool bookable { get; set; }
public int zone { get; set; }
public int seatsCount { get; set; }
public string area { get; set; }
public int bookedSeats { get; set; }
public int freeSeats { get; set; }
}
还有我在 HomeController 上的 GetBenches 方法
public async Task<ActionResult> GetBenches([DataSourceRequest] DataSourceRequest request)
{
BenchesService bService = new BenchesService();
List<Bench> obj = await bService.getBenches();
return Json(obj.Select(s => new Bench
{
id = s.id,
bookable = s.bookable,
name = s.name,
seatsCount = s.seatsCount,
zone = s.zone,
freeSeats = s.freeSeats,
area = s.area,
bookedSeats = s.bookedSeats
}).Distinct().ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
如果我可以在单元格内添加this type 的控件(“福利组件”列上的那个),我想知道我是否将 .ClientTemplate 添加到其中一列中
【问题讨论】:
-
是的,但仍然有一点困难:\ 仍然是 q 位新手。我想要的是替换我拥有的最后 2 列,其中这 2 列的值将用于创建迷你图(总座位数与预订座位数)
-
有没有机会给我更多的帮助?
标签: asp.net asp.net-mvc telerik telerik-grid