I've been working on change the class added to a table row of the grid based on the value of a specific cell. For some reason however my code doesn't actually seem to do anything. There are no errors it just doesn't apply a class to the row cell and I don't know why. Can someone do a sanity check for me and make sure I have the code correctly structured please.
The Grid
@(Html.Kendo().Grid<
Spoton_Areas_Test.ViewModels.VesselsViewModel
>()
.Name("Grid")
.Columns(columns => {
columns.Bound(c => c.fixture_work)
.Title("Work");
columns.Bound(c => c.vessel_status)
.Title("Status");
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Events(e=>e.DataBound("OnDataBound"))
.DataSource(dataSource => dataSource
.Ajax()
.Sort(sort =>
{
sort.Add(
company => company.owner_company).Ascending();
})
.PageSize(40)
.Model(model =>
{
model.Id(p => p.vessel_idx);
})
.Read(read => read.Action("vessels_Read", "Home"))
.Update(update => update.Action("vessels_Update", "Home"))
))
My Javascript
function
onDataBound(e) {
var
kendoGrid = $(
"#Grid"
).data(
"kendoGrid"
);
var
rows = e.sender.element.find(
"tbody tr"
);
for
(
var
i = 0; i < rows.length; i++) {
var
row = rows[i];
var
status = kendoGrid.dataItem(row).vessel_status;
if
(status =
"PPT"
) {
$(row.cells[3]).addClass(
"customRed"
);
}
}
}