In asp.net mvc page im using a telerik grid that looks like this
<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>
this is my Bench class:
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; }
}
and my GetBenches method on HomeController
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);
}
i would like to know if i add a .ClientTemplate to one of the columns if i can add a control of this type inside the cell (the one on the "Benefit components" column)
Well, you could start with something like this perhaps:
@(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.Variance).Title("Booked")
.ClientTemplate(Html.Kendo().Sparkline()
.Name("booked_#=name#"")
.Type(SparklineType.Column)
.Tooltip(tooltip => tooltip.Format("{0} booked"))
.DataSource(
.DataSource(ds => ds.Ajax()
.Read(read => read.Action("Read", "MyController", new { myId = Model.MyID })
)
.ToClientTemplate()
.ToHtmlString()
);
})
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With