On my current project, we make extensive use of the kendo grids. However, I'm not happy with our re-use strategy, which consists of cutting and pasting known-good templates into each view that needs them. Is there documentation that describes how to, for instance, turn a template into a partial view? The trick is that, since these are client grids, I need to pass selection data into them somehow as well.
Here's a code example of what we're doing:
<script id="feedbackFormTemplate" type="text/kendo-tmpl">
@(Html.Kendo().Grid<Intranet.Data.Review.Info.FeedbackFormInfo>()
.Name("CRTFeedbackForm_#=Pernr#")
.Columns(columns =>
{
columns.Template(@<text></text>).ClientTemplate("<div>CRT Reviewed Date : \\#=SubmissionDateString\\# | \\#=CorrectiveActionName\\# | \\#=SectionName\\# </div>");
})
.ClientDetailTemplateId("crtReasonTemplate")
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("CRTGetByInvestigatorAndCaseNumber", "FeedbackForm", new { pernr = "#=Pernr#", caseNumber=@Model.Case.CaseNumber }))
)
.Events(e => e
.DataBound("hideHeader")
)
.ToClientTemplate()
)
</script>
<script id="crtReasonTemplate" type="text/kendo-tmpl">
@(Html.Kendo().Grid<Intranet.Data.Review.Info.FeedbackFormReasonInfo>()
.Name("reason_#=FeedbackFormId#")
.TableHtmlAttributes(new { @class = "noHideHeader" })
.Columns(columns =>
{
columns.Bound(p => p.ItemNumber).HtmlAttributes(new { style="width: 8%"});
columns.Bound(p => p.ItemType).HtmlAttributes(new { style = "width: 8%" });
columns.Bound(p => p.ItemOrg).HtmlAttributes(new { style = "width: 8%" });
columns.Bound(p => p.ItemEventDateString).HtmlAttributes(new { style = "width: 8%" });
columns.Bound(p => p.FeedbackReasonName).HtmlAttributes(new { style = "width: 45%" });
columns.Bound(p => p.RebuttalStatus).HtmlAttributes(new { style = "width: 15%" });
})
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetReasonsByFeedbackFormId", "FeedbackForm", new { feedbackFormId = "#=FeedbackFormId#" }))
)
.ToClientTemplate()
)
</script>
The bottom template in particular is re-used verbatim in many different places. I tried doing this:
<script id="crtReasonTemplate" type="text/kendo-tmpl">
@{ Html.RenderPartial("_CustomerReworkFeedbackReasonTemplate", new Intranet.Web.Areas.QTrack.ViewModels.CustomerReworkReasonTemplateViewModel { FeedbackFormId = feedbackFormId}); }
</script>
But it doesn't like the way I'm trying to transmit the feedbackFormId variable.
Thanks in advance for any assistance you can provide.
Here's a code example of what we're doing:
<script id="feedbackFormTemplate" type="text/kendo-tmpl">
@(Html.Kendo().Grid<Intranet.Data.Review.Info.FeedbackFormInfo>()
.Name("CRTFeedbackForm_#=Pernr#")
.Columns(columns =>
{
columns.Template(@<text></text>).ClientTemplate("<div>CRT Reviewed Date : \\#=SubmissionDateString\\# | \\#=CorrectiveActionName\\# | \\#=SectionName\\# </div>");
})
.ClientDetailTemplateId("crtReasonTemplate")
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("CRTGetByInvestigatorAndCaseNumber", "FeedbackForm", new { pernr = "#=Pernr#", caseNumber=@Model.Case.CaseNumber }))
)
.Events(e => e
.DataBound("hideHeader")
)
.ToClientTemplate()
)
</script>
<script id="crtReasonTemplate" type="text/kendo-tmpl">
@(Html.Kendo().Grid<Intranet.Data.Review.Info.FeedbackFormReasonInfo>()
.Name("reason_#=FeedbackFormId#")
.TableHtmlAttributes(new { @class = "noHideHeader" })
.Columns(columns =>
{
columns.Bound(p => p.ItemNumber).HtmlAttributes(new { style="width: 8%"});
columns.Bound(p => p.ItemType).HtmlAttributes(new { style = "width: 8%" });
columns.Bound(p => p.ItemOrg).HtmlAttributes(new { style = "width: 8%" });
columns.Bound(p => p.ItemEventDateString).HtmlAttributes(new { style = "width: 8%" });
columns.Bound(p => p.FeedbackReasonName).HtmlAttributes(new { style = "width: 45%" });
columns.Bound(p => p.RebuttalStatus).HtmlAttributes(new { style = "width: 15%" });
})
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetReasonsByFeedbackFormId", "FeedbackForm", new { feedbackFormId = "#=FeedbackFormId#" }))
)
.ToClientTemplate()
)
</script>
The bottom template in particular is re-used verbatim in many different places. I tried doing this:
<script id="crtReasonTemplate" type="text/kendo-tmpl">
@{ Html.RenderPartial("_CustomerReworkFeedbackReasonTemplate", new Intranet.Web.Areas.QTrack.ViewModels.CustomerReworkReasonTemplateViewModel { FeedbackFormId = feedbackFormId}); }
</script>
But it doesn't like the way I'm trying to transmit the feedbackFormId variable.
Thanks in advance for any assistance you can provide.