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

[Solved] Cannot get CheckBox in Grid With Template as per sample

0 Answers 47 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.
Nimit
Top achievements
Rank 1
Nimit asked on 29 Mar 2011, 01:06 AM
Hi there,

I have replicated MVC->Grid->CheckBoxesAjax Sample in my code and tried it with my model.
My Model has fields as following :

OrderID
CustomerName
ShippingAddress

It does not display CheckBox at all.

Instead it Displays the Value of the Column (in this case OrderID).

I tried all possible solutions but I dont get to see checkBox instead no matter what I do I get the Value of the Model Field.

Check the Code Below:

@model IEnumerable<TGC.Models.TGCModel>
  
@{
    ViewBag.Title = "Index";
}
  
<div>
@{Html.Telerik().Grid(Model)
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(o => o.OrderID)
                    .ClientTemplate("<input type='checkbox' name='checkedRecords' value='<#= OrderID #>' />")
                    .Title("Select")
                    .Width(36)
                    .HtmlAttributes(new { style = "text-align:center" });
            columns.Bound(o => o.OrderID).Width(100);
            columns.Bound(o => o.ContactName).Width(200);
            columns.Bound(o => o.ShipAddress);
        })
        .DataBinding(dataBinding => dataBinding.Ajax().Select("_CheckBoxesAjax", "Grid"))
        .Scrollable()
        .Pageable()
        .Render();    
}
</div>
My Model is as shown Below
namespace TGC.Models
{
    public class TGCModel
    {
        public int OrderID;
        public string ShipAddress;
        public string ContactName;
    }
}

and Controller is as Following:
namespace TGC.Controllers
{
    public class GridController : Controller
    {
        //
        // GET: /Check/
  
        public ActionResult CheckBoxesAjax()
        {
            var newList = new List<TGCModel>();
            newList.Add(new TGCModel { OrderID = 1, ContactName = "Nimit", ShipAddress = "MR" });
            newList.Add(new TGCModel { OrderID = 2, ContactName = "NR", ShipAddress = "MSS" });
            newList.Add(new TGCModel { OrderID = 3, ContactName = "NNR", ShipAddress = "MRS" });
            return View(newList);
        }
  
        [GridAction]
        public ActionResult _CheckBoxesAjax()
        {
            var newList = new List<TGCModel>();
            newList.Add(new TGCModel { OrderID = 1, ContactName = "Nimit", ShipAddress = "MR" });
            newList.Add(new TGCModel { OrderID = 2, ContactName = "NR", ShipAddress = "MSS" });
            newList.Add(new TGCModel { OrderID = 3, ContactName = "NNR", ShipAddress = "MRS" });
            return View (newList);
        }
  
  
    }
}


Please Let me know what I am missing.

and all of them are just some Random Data Values in the fields    



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