我正在复制与此处显示的功能非常接近的功能。 https://onabai.wordpress.com/2013/07/17/kendoui-multiselect-in-a-grid-yes-we-can/Kendo Grid Inline MultiSelect - 发布的值
我有一个内联多选编辑器字段的Kendo网格。我有一个datasource.sync()事件开始改变多选。我遇到的问题是如何将数据安排在post变量中。
我在FireFox中使用FireBug。我可以设置一个函数在sync()事件中查看我的multiselect字段中的值。
console.log(this.value());
这将是一个字符串数组场我称之为“RoleCode”。总之,控制台日志显示的值,因为他们应该,例如
A, OU
然而,当我看到中邮呼吁我的控制器,并在参数,我看到了RoleCode场被复制,这是为什么我的控制器不能识别方法签名。例如,这是我在FireBug中看到的...
ID 123
Field1 TextFromField1
RoleCode[1][RoleCode] OU
RoleCode[] A
任何想法我应该如何设置它,以便后期参数可用?
UPDATE
现在我只是改变了更新功能来发送多选值作为逗号分隔字符串。我可以在控制器中处理它们。我不太喜欢这种设置,但是直到我发现如何让发布的值正确发送,这就是我要做的。
update: {
url: "Home/GridUpdate",
type: "POST",
dataType: "json",
data: function() {
//Grid does not post multiselect array correctly, need to convert to a string
var rolesString = $("#gridRoleList").data("kendoMultiSelect").value().toString();
return { rolesString: rolesString };
},
complete: function (e) {
setTimeout(function() {
refreshGrid();
}, 300);
},
success: function (result) {
// notify the data source that the request succeeded
options.success(result);
},
error: function (result) {
// notify the data source that the request failed
options.error(result);
}
},
更新2
其实这不是一个好主意,因为如果我在编辑网格中的另一个领域,我得到一个js错误,因为多选找不到。
感谢。我认为这是我需要的,但我没有使用MVC包装。任何想法如何通过datasource.sync()事件上的这些函数或传输的更新函数来运行数据? – madvora
您可以使用transport.read。数据函数从JS发送附加参数,请参考Kendo UI文档。 http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-transport.read.data –