This question is locked. New answers and comments are not allowed.
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:
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