Hi there. Here's my setup;
I have a grid and in the grid I bind to a column. The column has a template applied to it.
View
.Columns(current =>
{
current.Bound(p => p.CurrentMaterial).EditorTemplateName("ddl_Mixing_Materials_Current");
current.Group(g1 => g1.Title("Volumes")
.Columns(volume =>
{
volume.Bound(p => p.CurrentVol). EditorTemplateName("kIntegerNoSpinnerNoNegativesNamed"); <---//This one!
volume.Command(p => p.Custom("-20").Click("Remove20"));
})
);
Template
@model int?
@(Html.Kendo().NumericTextBoxFor(m => m)
.Name("NumericTextBox") <-- I know this will confuse the bounding - I changed just to make next step clearer
.HtmlAttributes(new { style = "width:100%" })
.Decimals(0)
.Placeholder("")
.Min(0)
.Max(500) <-- this is what I need to set after data binding!
.Spinners(false)
)
So the issue is, I need to set the max of each column depending on the object bound to it. Each object has a 'maxVolume' that I want to use to set the 'max' value in the template. However - I looked at the API page and I tried to access the numberTextBox like it suggests, but the textbox is always 'undefined'. Here's the script and how I'm trying to access the NumericTextBox
Script
function dataBound(e) {
var grid = this;
grid.tbody.find("tr[role='row']").each(function () {
var model = grid.dataItem(this);
var maxValue = model.MaxVolume;
alert(maxValue); <-- All good
var test2 = $(this).find("#NumericTextBox");
alert(test2); <-- Object found
var numericTextBox2 = $('#CurrentVol').data('numerictextbox');
alert(numericTextBox2); <-- 'Undefined'
var numericTextBox3 = $(this).find("#NumericTextBox").data('kendoNumericTextBox');
alert(numericTextBox3); < -- Still 'undefined'
});
}
So I'm clearly missing something. Is there some extra bit of traversal I need to do in my script because of the looping through grid rows I do? Am I looking for the wrong .data() type?
Any help would be great. thanks.