如何在网格的按钮单击事件中将所选行的对象从网格传递到窗口
。
<script>
function editItem(e) {
e.preventDefault();
var selectedObj= this.dataItem($(e.currentTarget).closest("tr"));
//selectedObj is object selected by user
var myWin = $("#windowstatus").kendoWindow({
width: "450px",
height: "250px",
title: "Some Title",
content: {
url: "../SomeURL", //controller name
data: { selectedObj } //passing obj to mvc controller
}
});
myWin.data("kendoWindow").open();
return false;
}
</script>
我的动作结果
public class XXX: Controller
{
public ActionResult Index(MyClass obj)
{
// Do Something
}
}
我无法在mvc控制器中接收该对象,并且始终为空
答案 0 :(得分:0)
var grid = $("#grid").data("kendoGrid");
var selectedItem = grid.dataItem(grid.select());
if (selectedItem != null && selectedItem != "" && selectedItem != undefined)
{
var wOptions =
{
content: "/xx/XxController/Index/" + selectedItem.Id//
If you have the parameter,
iframe: true,
modal: true,
width: "50%",
height: "90%",
close: function () {
this.destroy();
$('body').addClass('non-overflow');
},
open: function () {
this.center();
}
};
var windowParent = windowParent == undefined ? "list-splitter" : windowParent;
$("#" + windowParent).append("<div id='printWindow'> </div>")
$("#printWindow").kendoWindow(wOptions);
}
以下代码块也调用window js方法
window: function (url, params, windowParent) {
var wOptions = {
content: url + "/?frameFilter=" + params,
iframe: true,
modal: true,
width: "90%",
height: "90%",
close: function () {
this.destroy();
$('body').addClass('non-overflow');
},
open: function () {
this.center();
}
};
windowParent = windowParent == undefined ? "pop-splitter" : windowParent;
$("#" + windowParent).append("<div id='popupWindow'> </div>")
$("#popupWindow").kendoWindow(wOptions);
},
我希望对您有帮助