All the possible solutions in here could not solve my problem.
@(Html.Kendo().Grid<WishlistItem>()
.Name(
"gridWishlist"
)
.Columns(columns =>
{
columns.Bound(c => c.Kategorie.Name);
// How can I give the Editortemplate this information?
columns.Bound(c => c.Count).Width(100).EditorViewData(
new
{ MaxCount =
"# =WishlistItem_MaxCount#"
});
columns.Command(command =>
{
command.Destroy();
}).Width(130);
})
.DataSource(dataSource => dataSource
.Ajax()
.AutoSync(
true
)
.Events(ev => {
ev.Error(
"gridError"
);
ev.Sync(
"calculateKaution"
);
})
.Model(model =>
{
model.Id(m => m.Id);
model.Field(m => m.Kategorie.Name).Editable(
false
);
})
.PageSize(100)
// CRUD
.Read(r => r.Action(
"GetKategorieWishlist"
,
"Ausleihe"
))
.Destroy(
"DeleteKategorieInWishlist"
,
"Ausleihe"
)
)
.Editable(editable => editable
.Mode(GridEditMode.InCell)
)
.HtmlAttributes(
new
{ style = KendoManager.Grid_GetHeight(5,
false
,
true
) })
.Scrollable(scrollable => scrollable.Virtual(
true
))
.Sortable()
)
My EditorTemplate is
@model
double
?
@(Html.Kendo().NumericTextBoxFor(m => m)
.Decimals(0)
.HtmlAttributes(
new
{ style =
"width:100%"
})
// Max-Value is coming from Grid-ViewModel.
.Max(ViewData[
"MaxCount"
] !=
null
&& ViewData[
"MaxCount"
]
is
int
? (
int
)ViewData[
"MaxCount"
] : 0)
.Min(0)
)
In my page the user can add existing datasets from combobox into this grid I'll talk about.
The Grid ViewModel is carrying a property with a total count of exemplars of the dataset (WishlistItem_MaxCount). It should be passed into my EditorTemplate, that the NumericTextBox of the Property "Count" has this Max-Value in his settings.
All the solutions in this thread here are talking about comboboxes and dropdownboxes with a defined datasource, but not in my case with a NumericTextBox.
As far I unterstood I can't send the property WishlistItem_MaxCount to my EditorTemplate because the grid is only initialized once at the beginning. So all the dynamically added datasets of my grid can't be applied to this max-amount.
Is there any possible solution to my case?