Kendo window 刷新不起作用
Kendo window refresh does not work
我被困在一个看似非常简单的场景中:
使用绑定到模型的局部视图加载 Kendo window,动态参数 modelId
将由客户端 js 提供。
我发现了 refresh()
方法,但这意味着已经有一个 kendo window 初始化。这是第一个问题。我需要 modelId
来显示内容。
所以我解决了这个问题,并简单地返回了一个新模型,该模型最初应该是 refresh()
方法的 replaced/refreshed + 有效参数 modelId
并最终显示出来。
问题:视图不会更新。
不过,refresh()
方法确实有效。
控制器接收参数modelId
,获取相应的模型和returns视图。但是 Kendo window 仍然持有空的视图模型。
我真的很努力让这个工作但没有成功..
@(Html.Kendo().Window()
.Name("window")
.Title("")
//loads an empty viewmodel intially as there is no possibility to pass parameter
.LoadContentFrom("Actionname", "Controller")
.Actions(actions => actions.Close())
.Modal(true).Visible(false)
.HtmlAttributes(new {style = "margin: 10px"})
)
Javascript 片段:
$("#window").data("kendoWindow").refresh({
url: '/controller/actionname/',
data: { parameterlabel: parameter}
});
$("#window").data("kendoWindow").open().center(true);
不确定这是否能解决您的主要问题,但您应该可以这样做:
@(Html.Kendo().Window()
.Name("window")
.Title("")
.LoadContentFrom("Actionname", "Controller", new { modelID = modelId })
.Actions(actions => actions.Close())
.Modal(true).Visible(false)
.HtmlAttributes(new {style = "margin: 10px"})
)
那么您就不需要加载空模型并使用正确的参数刷新它。
..会不会是我弄错了,refresh() 方法实际上不需要完全加载 kendo window 内容?我在 teleriks 页面上找到了这个:“
如果你想动态加载window中的内容(通过AJAX),你可以这样做:
//set up kendo window
$(document).ready(function () {
var window = $("#window").kendoWindow({
height: "200px",
modal: true,
title: "Centered Window",
visible: false,
width: "200px"
}).data("kendoWindow");
});
//using the refresh method after the window has been intialized:
var dialog = $("#window").data("kendoWindow");
dialog.refresh({
url: "/search",
data: { query: "foobar" }
}); "
.. 不是我期望的刷新但好吧..
所以也许我应该删除创建的 kendo window:
中的加载内容
@(Html.Kendo().Window()
.Name("window")
.Title("")
//.LoadContentFrom("Actionname", "Controller", new { modelID = modelId })
.Actions(actions => actions.Close())
.Modal(true).Visible(false)
.HtmlAttributes(new {style = "margin: 10px"})
)
我第一次看到这个问题:
wnd.refresh({
url: msg.Url,
type: "POST",
contentType: "application/json",
dataType: "json",
data: msg.Data
});
而 Kendo Window 是空的。 Fiddler 中的请求(一些 headers 和数据已删除):
POST http://localhost/My/PtsSchedule/Pts_AddBooking HTTP/1.1
Accept: application/json, text/javascript, */*; q=0.01
Content-Type: application/json
问题显然出在:
Accept: application/json, text/javascript, /; q=0.01
并删除 dataType: 为我解决了这个问题。这里新刷新:
wnd.refresh({
url: msg.Url,
type: "POST",
contentType: "application/json",
data: msg.Data
});
在 Fiddler 中:
POST http://localhost/My/PtsSchedule/Pts_AddBooking HTTP/1.1
Accept: text/html, */*; q=0.01
Content-Type: application/json
内容显示在KendoWindow内。希望这是来自帮助。
我被困在一个看似非常简单的场景中:
使用绑定到模型的局部视图加载 Kendo window,动态参数 modelId
将由客户端 js 提供。
我发现了 refresh()
方法,但这意味着已经有一个 kendo window 初始化。这是第一个问题。我需要 modelId
来显示内容。
所以我解决了这个问题,并简单地返回了一个新模型,该模型最初应该是 refresh()
方法的 replaced/refreshed + 有效参数 modelId
并最终显示出来。
问题:视图不会更新。
不过,refresh()
方法确实有效。
控制器接收参数modelId
,获取相应的模型和returns视图。但是 Kendo window 仍然持有空的视图模型。
我真的很努力让这个工作但没有成功..
@(Html.Kendo().Window()
.Name("window")
.Title("")
//loads an empty viewmodel intially as there is no possibility to pass parameter
.LoadContentFrom("Actionname", "Controller")
.Actions(actions => actions.Close())
.Modal(true).Visible(false)
.HtmlAttributes(new {style = "margin: 10px"})
)
Javascript 片段:
$("#window").data("kendoWindow").refresh({
url: '/controller/actionname/',
data: { parameterlabel: parameter}
});
$("#window").data("kendoWindow").open().center(true);
不确定这是否能解决您的主要问题,但您应该可以这样做:
@(Html.Kendo().Window()
.Name("window")
.Title("")
.LoadContentFrom("Actionname", "Controller", new { modelID = modelId })
.Actions(actions => actions.Close())
.Modal(true).Visible(false)
.HtmlAttributes(new {style = "margin: 10px"})
)
那么您就不需要加载空模型并使用正确的参数刷新它。
..会不会是我弄错了,refresh() 方法实际上不需要完全加载 kendo window 内容?我在 teleriks 页面上找到了这个:“ 如果你想动态加载window中的内容(通过AJAX),你可以这样做:
//set up kendo window
$(document).ready(function () {
var window = $("#window").kendoWindow({
height: "200px",
modal: true,
title: "Centered Window",
visible: false,
width: "200px"
}).data("kendoWindow");
});
//using the refresh method after the window has been intialized:
var dialog = $("#window").data("kendoWindow");
dialog.refresh({
url: "/search",
data: { query: "foobar" }
}); "
.. 不是我期望的刷新但好吧.. 所以也许我应该删除创建的 kendo window:
中的加载内容@(Html.Kendo().Window()
.Name("window")
.Title("")
//.LoadContentFrom("Actionname", "Controller", new { modelID = modelId })
.Actions(actions => actions.Close())
.Modal(true).Visible(false)
.HtmlAttributes(new {style = "margin: 10px"})
)
我第一次看到这个问题:
wnd.refresh({
url: msg.Url,
type: "POST",
contentType: "application/json",
dataType: "json",
data: msg.Data
});
而 Kendo Window 是空的。 Fiddler 中的请求(一些 headers 和数据已删除):
POST http://localhost/My/PtsSchedule/Pts_AddBooking HTTP/1.1
Accept: application/json, text/javascript, */*; q=0.01
Content-Type: application/json
问题显然出在:
Accept: application/json, text/javascript, /; q=0.01
并删除 dataType: 为我解决了这个问题。这里新刷新:
wnd.refresh({
url: msg.Url,
type: "POST",
contentType: "application/json",
data: msg.Data
});
在 Fiddler 中:
POST http://localhost/My/PtsSchedule/Pts_AddBooking HTTP/1.1
Accept: text/html, */*; q=0.01
Content-Type: application/json
内容显示在KendoWindow内。希望这是来自帮助。