I am trying to use a Webgrid and I can get the data to display but the bool values are where I'm having problems. I would like to just display a checkbox that has the value of my bool. I have been able to get a checkbox within the grid but it is editable and does not show the value correctly.
grid.GetHtml(tableStyle: "table", alternatingRowStyle: "alternate", headerStyle: "header",
columns: grid.Columns(grid.Column(columnName: "string1", header: "String1", format: @<text>@item.string1</text>),
grid.Column(columnName: "bool1", header: "bool1", format: bool1? </text>),
If someone has done this before and could shed some light on how to properly display a bool as a checkbox that would be appreciated!
Try this for the bool column:
grid.Column(columnName: "bool1",
header: "bool1",
format: (item) => @Html.Raw("<input type='checkbox' " + ((item.bool1==true) ? "checked" : "") + " disabled='disabled' />")
)
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