This question is locked. New answers and comments are not allowed.
Hi,
I noticed a strange issue when trying to rebind grid.
This code works fine(LineID is passed to Details grid as parameter to do data binding):
But When I modified it to use Datatable and Datarow instead of Detail class what is defined by myself, the rebind doesn't works at all:
Can anyone help me to figure out what's wrong with it if I use IEumerable<DataRow> instead of IEnumberable<Detail>?
Thanks!!
I noticed a strange issue when trying to rebind grid.
This code works fine(LineID is passed to Details grid as parameter to do data binding):
In View:@(Html.Telerik().Grid((IEnumerable<Detail>)ViewData["DetailsData"]) .Name("Details") .DataKeys(keys => { keys.Add("LineID"); }) .Columns(columns=> { columns.Bound(typeof(string), "LineID").Visible(false); columns.Bound(typeof(string), "Name").Width(400).Title("Name"); columns.Bound(typeof(string), "TotalNumber").Width(300).Title("TotalNumber"); }) .DataBinding(dataBinding => dataBinding.Ajax().Select("_DetailsAjax", "Test", new { LineID = "<#= LineID #>" })) .ClientEvents(clientEvents => clientEvents.OnDataBinding("details_onDataBinding")) .Pageable() .Sortable())In Controller:[GridAction]public ActionResult _DetailsAjax(int LineID){ return View(new GridModel<Detail> { Data = GetDetails(LineID) });} public IList<Detail> GetDetails(int LineID){ List<Detail> details = new List<Detail>();
// Get detail data return details;}But When I modified it to use Datatable and Datarow instead of Detail class what is defined by myself, the rebind doesn't works at all:
In View:@(Html.Telerik().Grid((IEnumerable<System.Data.DataRow>)ViewData["DetailsData"]) .Name("Details") .DataKeys(keys => { keys.Add("LineID"); }) .Columns(columns=> { columns.Bound(typeof(string), "LineID").Visible(false); columns.Bound(typeof(string), "Name").Width(400).Title("Name"); columns.Bound(typeof(string), "TotalNumber").Width(300).Title("TotalNumber"); }) .DataBinding(dataBinding => dataBinding.Ajax().Select("_DetailsAjax", "Test", new { LineID = "<#= LineID #>" })) .ClientEvents(clientEvents => clientEvents.OnDataBinding("details_onDataBinding")) .Pageable() .Sortable()) In Controller:[GridAction]public ActionResult _DetailsAjax(int LineID){ return View(new GridModel<System.Data.DataRow> { Data = GetDetails(LineID) });} public IEnumerable<System.Data.DataRow> GetDetails(int LineID){ DataTable details = new DataTable(); // Get detail data return details.AsEnumerable();;}Can anyone help me to figure out what's wrong with it if I use IEumerable<DataRow> instead of IEnumberable<Detail>?
Thanks!!