This is a migrated thread and some comments may be shown as answers.

[Solved] Grid: Bool Displays true,false, not checkbox

0 Answers 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
bbeatty
Top achievements
Rank 1
bbeatty asked on 10 Feb 2012, 11:13 PM
I have a Ajax bound grid. It will only show true,false for a boolean value. I would like it to show a disabled check, like the examples.

//model
 [KnownType(typeof (RaceResult))]
    public class RaceResult
    {
         
         
        public string Runner { get; set; }
 
        [Required]      
        public int RunnerId { get; set; }
 
        [Key]
        [ReadOnly(true)]
        public int Id { get; set; }
 
        public bool IsBook { get; set; }
    }
 
//View
@(Html.Telerik().Grid<RaceResult>()
    .Name("Runners")
    .DataKeys(keys => keys.Add(p => p.Id))
    .DataBinding(dataBinding => dataBinding.Ajax().Select("RunnerBinding", "Grid1")
                .Insert("RunnerInsert", "Grid1")
                .Update("RunnerUpdate", "Grid1"))
    .Columns(columns =>
                    {
                        columns.Bound(o => o.Id).Width(100);
                        columns.Bound(o => o.Runner).Width(200);
                        columns.Bound(o => o.IsBook);
                        columns.Command(commands =>
                        {
                            commands.Edit().ButtonType(GridButtonType.BareImage);
                              
                        }).Width(200).Title("Commands");
                    })
 
    .Editable(editing => editing.Mode(GridEditMode.InLine))
    )
 
 
//controller
   [GridAction]
        [HttpPost]
        public virtual ActionResult RunnerBinding()
        {
    
            return View(new GridModel<RaceResult> {Data = RaceResults()});
        }
 
        private List<RaceResult> RaceResults()
        {
            var raceResult = new List<RaceResult>();
            var runner = new Runner {Id = 1, Name = "Brian"};
            var runner2 = new Runner {Id = 2, Name = "Sam"};
            raceResult.Add(new RaceResult {Id = 1, RunnerId = 1, Runner = runner.Name});
            raceResult.Add(new RaceResult {Id = 2, RunnerId = 2, Runner = runner2.Name});
            raceResult.Add(new RaceResult {Id = 3, RunnerId = 1, Runner = runner.Name});
            return raceResult;
        }
This is what I see

Id   Runner      IsBook  Commands
1    Brian      false      <Edit>
2    Sam        false      <Edit>
3    Brian      false      <Edit>

What am I doing wrong?

Thanks

Tags
Grid
Asked by
bbeatty
Top achievements
Rank 1
Share this question
or