1

Currently I am having this code for displaying a KendoUI grid:

@(Html.Kendo().Grid<CleverFit.Models.MyHistorie>()
      .Name("grid")
      .DataSource(dataSource => dataSource // Configure the grid data source
          .Ajax() // Specify that ajax binding is used
          .Read(read => read.Action("Products_Read", "Action")) // Set the action method which will return the data in JSON format
       )
      .Columns(columns =>
      {
        columns.Bound(product => product.Datum).Format("{0:dd.MM.yyyy}");
        columns.Bound(product => product.Aktion);
        columns.Bound(product => product.Ergebnis);
        columns.Bound(product => product.Wiedervorlage).Format("{0:dd.MM.yyyy H:mm}");
        columns.Bound(product => product.Bemerkung);
        columns.Bound(product => product.Erledigt);
      })
      .Pageable() // Enable paging
      .Sortable() // Enable sorting
)

I tried already this:

columns.Bound(product => product.Erledigt).ClientTemplate(
    "<input type='checkbox' value='#= ProductID #' " +
        "# if (Enabled) { #" +
            "checked='checked'" +
        "# } #" +
    "/>"
);

But if I add this, there is no data displayed in the grid...

The values of the last column which is product.Erledigt are displayed as true or false. Is it possible to display them as checkboxes?

I am using Telerik KendoUI and loading the content of the template via AJAX.

1 Answer 1

1

You can check the following FAQ page:

http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/faq#how-to-display-checkboxes-in-ajax-bound-grids

In addition, you can make the checkbox readonly or disabled to prevent the user from editing it and expect the changes to be persisted.

Update

The code that you have tried contains two data field values, which obviously do not exist in your Grid: ProductID and Enabled. Most probably you are getting a JavaScript error in the browser console. Replace Enabled with Erledigt and remove value='#= ProductID #' if you don't need such a thing.

Sign up to request clarification or add additional context in comments.

3 Comments

thanks for the quick answer but if I add exact the same code, the grid is not displaying any data
Perfect that did it!
do you also know how to disable it from editing? I would prefer to do it with Kendo (HtmlHelper) and not the html from ClientTemplate

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.