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

binding Model to MVC Telerik Grid throws error (ControllerContext Null Exception)

0 Answers 60 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.
HaBo
Top achievements
Rank 1
HaBo asked on 19 Mar 2012, 05:58 PM
I have multiple partialviews rendered on to one view,

each partial view is a strongly typed(different Models) Telerik MVC Grid.

For first two grids those are rendered from partial views has no problem.

but for the third partial view i am rendering is throwing NULL exception.

I have posted my code here.
StackOverFlow

exception:
System.Web.Mvc.ChildActionValueProviderFactory.GetValueProvider(ControllerContext controllerContext)
Controller:
[GridAction]
           
public ActionResult CopaySummaryLevel(int PBMID)
           
{
               
CopayModel cModel = new CopayModel();
               
List<CopayModel> _CopayModel = cModel.GetSummaryLevelCopay(PBMID);
               
return PartialView("_CopayGridSummaryLevel", new GridModel<CopayModel>
               
{
                   
Data = _CopayModel
               
});
           
}
View:
 @model IEnumerable<HRORx.Models.BenefitsFormularyModel>
@using Telerik.Web.Mvc.UI
<h4>
   
Summary Level Copay</h4>
@(Html.Telerik().Grid<HRORx.Models.CopayModel>()
           
.Name("CopaySummaryLevel")
       
.Columns(columns =>
       
{
           
//columns.Bound(e => e.PharmacyType).Title("Pharmacy Type");
            columns
.Bound(e => e.OutOfPocketRangeStart);//.Title("OP Start");
           
//columns.Bound(e => e.OutOfPocketRangeEnd).Title("OP End");
           
//columns.Bound(e => e.FlatCopayAmount).Title("Flat Fee");
           
//columns.Bound(e => e.PercentCopayRate).Title("% Copay");
           
//columns.Bound(e => e.MinimumCopay).Title("Min. Copay");
            columns
.Bound(e => e.MaximumCopay);//.Title("Max. Copay");//.Format("{0:c}")
       
})
   
.ClientEvents(events => events.OnRowDataBound("Record_onRowDataBound"))
       
.ClientEvents(ev => ev.OnComplete("ShowOrHide"))
                               
.DataBinding(dataBinding => dataBinding.Ajax().Select("CopaySummaryLevel", "BenefitsFormulary", new { PBMID = Model.FirstOrDefault().HealthPlanMappingID }))
       
.Pageable(paging => paging.PageSize(3))
       
.NoRecordsTemplate("No Summary Level Copy Information is available for this Medication.")
       
.Sortable()
)
Row bind Event:
function Record_onRowDataBound(e) {
   
var grid = $(this).data('tGrid');
}

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