This question is locked. New answers and comments are not allowed.
I have a custom editortemplate that I need to pass a value to in order to have conditional display logic.
My master grid has a field called Unlimited. I need to pass the value to the editortemplate and then have a if condition based on that value when a detailview child edit or insert is executed.
On the onedit of my detail view I have the on edit event:
.ClientEvents(events => events.OnEdit("onEditSlots"))
But the line that reads:
var parentDataItem = masterRow.closest('.t-grid').data('tGrid').dataItem(masterRow);
gives me an error saying dataItem is null.
In my editortemplate, I want an if condition if unlimitedslots = true else if unlimitedslots = false execute something else.
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MVCProject.ViewModels.SlotViewModel>" %>
<%= Html.TextBox("UnlimitedSlots").value.Equals(true) ? "Slots: Unlimited" : "Slots:" + Html.TextBoxFor(x => x.Slots) %>
my grid detail view that is displayed in a tab:
items.Add().Text("Slots").Content(
Html.Telerik().Grid<MVCProject.ViewModels.SlotViewModel>()
.Name("Slots_<#= \ID #>")
.ToolBar(commands => commands.Insert())
.DataKeys(keys => keys.Add(f => f.SlotID))
.ClientEvents(events => events.OnEdit("onEditSlots"))
//ommitted for brevity
.ToHtmlString());
My master grid has a field called Unlimited. I need to pass the value to the editortemplate and then have a if condition based on that value when a detailview child edit or insert is executed.
On the onedit of my detail view I have the on edit event:
.ClientEvents(events => events.OnEdit("onEditSlots"))
function onEditSlots(e) {
var dataItem = e.dataItem;
var mode = e.mode;
var form = e.form;
var txt = $(form).find("#UnlimitedSlots");
var masterRow = $(e.form).closest('.t-detail-row').prev();
var parentDataItem = masterRow.closest('.t-grid').data('tGrid').dataItem(masterRow);
if (mode == "insert") {
txt.val(parentDataItem["UnlimitedSlots"]);
}
if (mode == "edit") {
txt.val(dataItem["UnlimitedSlots"]);
}
}
But the line that reads:
var parentDataItem = masterRow.closest('.t-grid').data('tGrid').dataItem(masterRow);
gives me an error saying dataItem is null.
In my editortemplate, I want an if condition if unlimitedslots = true else if unlimitedslots = false execute something else.
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MVCProject.ViewModels.SlotViewModel>" %>
<%= Html.TextBox("UnlimitedSlots").value.Equals(true) ? "Slots: Unlimited" : "Slots:" + Html.TextBoxFor(x => x.Slots) %>
my grid detail view that is displayed in a tab:
items.Add().Text("Slots").Content(
Html.Telerik().Grid<MVCProject.ViewModels.SlotViewModel>()
.Name("Slots_<#= \ID #>")
.ToolBar(commands => commands.Insert())
.DataKeys(keys => keys.Add(f => f.SlotID))
.ClientEvents(events => events.OnEdit("onEditSlots"))
//ommitted for brevity
.ToHtmlString());