Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Change the displayed name of a column item
    primarykey
    data
    text
    <p>I have a kendo gridview where one of the columns is for a boolean value. In the column, the information comes up labeled either "true" (for 1 or true), "false" (for 0 or false), or blank (for null). This does not look very professional, and I am trying to change these values in the grid to instead be displayed as Yes, No, or None (respectively). The code I am using to try to make this happen is:</p> <p><strong>Model:</strong></p> <pre><code>namespace MvcApplication.Models { public class Companies { public string IsAdmitted { get; set; } </code></pre> <p><strong>Controller:</strong></p> <pre><code> [HttpPost] public ActionResult Companies_Read([DataSourceRequest] DataSourceRequest request) { using (var companydata = new CompaniesDataContext()) { List&lt;Companies&gt; model = new List&lt;Companies&gt;(); var companylist = companydata.Companies_JBs.Select(s =&gt; s).ToList(); foreach (var h in companylist) { Companies x = new Companies(); x.IsAdmitted = h.IsAdmitted == (bool)true ? x.IsAdmitted = "Yes" : h.IsAdmitted == (bool)false ? x.IsAdmitted = "No" : x.IsAdmitted = "Null"; model.Add(x); } return Json(companydata.Companies_JBs.ToDataSourceResult(request)); } } </code></pre> <p><strong>View:</strong></p> <pre><code>@(Html.Kendo().Grid(Model) .Name("Company_Grid") .Columns(columns =&gt; { columns.Bound(o =&gt; o.IsAdmitted).Title("Admitted:").Width(95); columns.Command(command =&gt; { command.Edit(); command.Destroy(); }); } ) .ToolBar(toolbar =&gt; toolbar.Create().Text("Add a Company")) .Editable(editable =&gt; editable.Mode(GridEditMode.PopUp).TemplateName("Companies")) .Pageable() .Sortable() .Scrollable() .HtmlAttributes(new { style = "height:430px;" }) .DataSource(dataSource =&gt; dataSource .Ajax() .PageSize(20) .Events(events =&gt; events.Error("error_handler")) .Model(model =&gt; model.Id(o =&gt; o.ID)) .Create(update =&gt; update.Action("Companies_Create", "Home")) .Update(update =&gt; update.Action("Companies_Update", "Home")) .Destroy(update =&gt; update.Action("Companies_Destroy", "Home")) .Read(read =&gt; read.Action("Companies_Read", "Home")) ) ) </code></pre> <p>When I put a breakpoint and check the value, it says that the IsAdmitted field items are labelled as Yes, No, or None (depending on their value in my sql database). However, in the grid itself they are still labeled true, false, or blank. Whats my problem here, Or is there a better way to do this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload