好吧,我真的被困在这里。Telerik的示例显示了如何在编辑所需的任何内容时更改字段。到底,
columns: [
{ field: "Category", title: "Category", width: "180px", editor: categoryDropDownEditor, template: "#=Category.CategoryName#" },
],
...其中"类别Dropdowneditor"是一个可以解决问题的客户端函数。
在MVC版本中,似乎没有任何类型。有没有?我一直相信应该这样做。每次我需要装饰输入字段时,我都不需要从服务器遍历部分HTML。这似乎是唯一可用于MVC的" Editortemplate"。
好。如果任何人都会碰到同样的情况。我最终得到了这个"太优雅"的解决方案:
.Events(e => e.Edit("editing"))
网格初始化例程(服务器端)中的此行调用命名动态方法(客户端):
function editing(e) {
var input = e.container.find("input[name=Regex]");
var textbox = $(document.createElement('textarea')).attr({
id: input.id,
}).width(input.width()).height(input.height()).val(input.val());
input.hide();
textbox.insertAfter(input);
textbox.focus(function () {
/*to make this flexible, I'm storing the current width & height in an attribute*/
$(this).attr('data-defaultwidth', $(this).width());
$(this).attr('data-defaultheight', $(this).height());
$(this).animate({
width: 400
}, 'slow');
$(this).animate({
height: 300
}, 'slow');
}).blur(function () {
/* lookup the original width */
var w = $(this).attr('data-defaultwidth');
var h = $(this).attr('data-defaultheight');
$(this).animate({
width: w
}, 'slow');
$(this).animate({
height: h
}, 'slow');
input.val(textbox.val());
input.trigger('change');
});
}
结束tada,尽管它是一个纯粹的黑客。