function
onError(error, inputElement) {
// 'this' is the form element
var
container = $(
this
).find(
"[data-valmsg-for='"
+ escapeAttributeValue(inputElement[0].name) +
"']"
),
replaceAttrValue = container.attr(
"data-valmsg-replace"
),
replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) !==
false
:
null
;
//replace = $.parseJSON(container.attr("data-valmsg-replace")) !== undefined;
container.removeClass(
"field-validation-valid"
).addClass(
"field-validation-error"
);
error.data(
"unobtrusiveContainer"
, container);
if
(replace) {
container.empty();
error.removeClass(
"input-validation-error"
).appendTo(container);
}
else
{
error.hide();
}
var
element = inputElement;
// Set positioning based on the elements position in the form
var
elem = $(element),
//corners = ['left center', 'right center'],
corners = [
'bottom left'
,
'top center'
],
flipIt = elem.parents(
'span.right'
).length > 0;
// Check we have a valid error message
if
(!error.is(
':empty'
)) {
// Apply the tooltip only if it isn't valid
elem.filter(
':not(.valid)'
).qtip({
overwrite:
false
,
content: error,
position: {
my: corners[flipIt ? 0 : 1],
at: corners[flipIt ? 1 : 0],
viewport: $(window)
},
show: {
event:
false
,
ready:
true
},
hide:
false
,
style: {
classes:
'qtip-red'
// Make it red... the classic error colour!
}
})
// If we have a tooltip on this element already, just update its content
.qtip(
'option'
,
'content.text'
, error);
}
// If the error is empty, remove the qTip
else
{ elem.qtip(
'destroy'
); }
}
01.
$('#txtReceiptee').kendoAutoComplete({
02.
filter: "startswith",
03.
dataTextField: "Name",
04.
dataSource: new kendo.data.DataSource({
05.
type: "json",
06.
transport: {
07.
read: {
08.
type: "POST",
09.
url: "AJAXReceiptee.asmx/GetReceipteeNames",
10.
contentType: 'application/json; charset=utf-8',
11.
datatype: "json",
12.
data: function ()
13.
{
14.
return {
15.
context: $("#txtReceiptee").data("kendoAutoComplete").value().replace(/\ /g, '%')
16.
}
17.
}
18.
19.
},
20.
parameterMap: function (options)
21.
{
22.
return JSON.stringify(options);
23.
}
24.
},
25.
serverFiltering: true,
26.
serverSorting: true,
27.
pageSize: 10,
28.
schema: {
29.
data: "d"
30.
} // schema
31.
})
32.
33.
});
01.
$('<
input
>').kendoAutoComplete({
02.
filter: "startswith",
03.
dataTextField: "Name",
04.
dataSource: new kendo.data.DataSource({
05.
type: "json",
06.
transport: {
07.
read: {
08.
type: "POST",
09.
url: "AJAXReceiptee.asmx/GetReceipteeNames",
10.
contentType: 'application/json; charset=utf-8',
11.
datatype: "json",
12.
data: function ()
13.
{
14.
return {
15.
context: $(" ?????? ").data("kendoAutoComplete").value().replace(/\ /g, '%')
16.
}
17.
}
18.
19.
},
20.
parameterMap: function (options)
21.
{
22.
return JSON.stringify(options);
23.
}
24.
},
25.
serverFiltering: true,
26.
serverSorting: true,
27.
pageSize: 10,
28.
schema: {
29.
data: "d"
30.
} // schema
31.
})
32.
33.
});
I have a Kendo grid that has a requirement for using a conditional dropdown in combination with batch editing.
For instance I need to allow an order enterer set the color of a product from a dropdown, but each product has a potentially different set of available colors.
I have done something similar with InLine editing without a problem and the ajax call to populate the dropdown is getting called correctly in batch mode. The problem appears to be that the #=productId# is not getting correctly parsed by Kendo.
@( Html.Kendo().Grid<Web.Models.StudentGradeView>()
.Name("Students")
.Columns(columns =>
{
columns.Bound(c => c.Id);
columns.Bound(c => c.Price);
columns.Bound(c => c.Color); })
.ToolBar(toolbar =>
{
toolbar.Template( @"
<span class=""pull-left"">
<a class=""btn k-grid-save-changes"" href=""javascript:void(0)""><span class=""k-icon k-update""></span> Save</a>
<a class=""btn k-grid-cancel-changes"" href=""javascript:void(0)""><span class=""k-icon k-cancel""></span> Cancel</a>
</span>"
})
.Events(e => e.Edit("onEdit")) .Editable(editable => editable.Mode(GridEditMode.InCell))
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.Events(events =>
{
events.Error("error_handler");
})
.Model(model =>
{
model.Id(m => m.Id);
})
.Read(read => read.Action("Product_Read", "Home", new { id = orderId }))
.Update(update => update.Action("Product_Update", "Home"))
)
)
@model string
@(
Html.Kendo().DropDownListFor(m => m)
.OptionLabel("Select Color")
.DataTextField("Color")
.DataValueField("Color")
.DataSource(dataSource =>
{
dataSource.Read("ColorsDropDown_Read", "DropDowns", new { Area = "", id = "#=ProductId#" });
})
)
public ActionResult ColorsDropDown_Read([DataSourceRequest] DataSourceRequest request, string id)
{
List<Grade> rVal = new List<Color>();
rVal = _SystemSettings.AllColors.Where(w => w.ProductId == id)..ToList();
return Json(rVal, JsonRequestBehavior.AllowGet);
}
Thanks!