Bart Schelkens
Bart Schelkens

Reputation: 1293

Display conditional image in kendo grid

I have a Kendo grid which displays some data. Now I want to add an image-column.

I tried it like this :

@(Html.Kendo().Grid<TegelCheckerModel>()
            .Name("Grid")
            .Columns(columns =>
            {
                columns.Bound(p => p.IsTegelZichtbaar).ClientTemplate("#= getImage(data)#");
            })
            .AutoBind(true)
            .Pageable()
            .Sortable()
            .Filterable()
            .DataSource(dataSource => dataSource
            .Ajax() //Or .Server()
            .Read(read => read.Action("GetTegels", "TegelChecker")
            .Data("getAlvNummerAndVoorWie"))
            )
        )

and then in js I do the following :

function getImage(data) {
            var html;

            if (data.IsTegelZichtbaar) {
                html = "<img src='~/Images/valid.jpg' />";
            }
            else{
                html = "<img src='~/Images/notvalid.jpg' />";
            }
            return html;
        }

The images exist but they are not displayed. What am I missing? What am I not seeing?

Upvotes: 0

Views: 1854

Answers (1)

Bart Schelkens
Bart Schelkens

Reputation: 1293

There was a problem with uploading the image. SO that is why it was not displaying. Stupid me for not checking that.

Upvotes: 1

Related Questions