Reputation: 344
I want to be able to display a boolean field as a checkbox but I can't find anything on the internet which gives a solution. See below, I've tried to return html which renders a checkbox but the entries are all false and they are editable, which I don't want.
Can someone point out what I'm doing wrong please? Why is this so HARD!? (Should I be solving this with CSS?) Many thanks, Pete
@Html.Grid(new GridControl()
.SetName("grid")
.SetListUrl(Url.Action("SearchForRequest", "Requests"))
.SetPageSize(100)
.SetIsAutoSize(true)
.SetHttpVerb(HttpVerbs.Post)
.SetHeight("300")
.SetAdditionalAttributes(",datatype:'local'")
.SetColumns<RequestSummaryViewModel>(cs =>
{
cs.Add(x => x.EvidenceRequired).SetCaption("Evidence Required").SetFormatter("function (cellvalue, options, rowObject) {return '<input type=checkbox value=' + cellvalue + '/>'}");
Upvotes: 3
Views: 4660
Reputation: 221997
I don't know which control base on jqGrid you use, but I guess that you can use the predefined 'checkbox' formatter with SetFormatter('checkbox')
instead of the usage of custom formatter.
Upvotes: 3
Reputation: 9271
I don't use JQGrid but if the Html you output is correct, then simply add the readonly
attribute to your input and the checked
attribute if the value is true.
This, in theory, should solve your problem.
Also this answer should be of help.
Upvotes: 0