当页面上发生单独的客户端操作时,我想按需刷新 TabControl 中的选项卡。我已将 TabControl 扩展(也尝试过 PageControl)放在 CallbackPanel 中,并且 EndCallBack 事件永远不会触发。如果 ShowLoadingPanel 设置为 true,您会看到调用挂起,因为加载面板永远不会消失。OnBeginCallback 和实际的 Controller 回调动作都会被执行。我假设面板和选项卡之间发生了某种冲突的回调,但我不知道如何解决它。如果我用基本的 html 或其他更简单的 DevExpress 控件替换 TabControl,一切正常。
TabControl 部分(CallbackTestPageControl.cshtml):
@Html.DevExpress().TabControl(settings => {
settings.Name = "testTabControl";
settings.Width = Unit.Percentage(100);
settings.Tabs.Add("tab 1");
settings.Tabs.Add("tab 2");
settings.Tabs.Add("tab 3");
}).GetHtml()
面板部分(CallbackTestPanel.cshtml):
@Html.DevExpress().CallbackPanel(settings =>
{
settings.Name = "cbpTabStrip";
settings.CallbackRouteValues = new { Controller = "Home", Action = "CallbackTestPanel" };
settings.ClientSideEvents.BeginCallback = "OnBeginCallback";
settings.ClientSideEvents.EndCallback = "OnEndCallback";
settings.SetContent(() => Html.RenderPartial("CallbackTestPageControl"));
}).GetHtml()
查看(CallbackTest.cshtml):
<script type="text/javascript">
var testId = null;
function ButtonClicked(s, e) {
alert('click');
testId = 1;
if (!cbpTabStrip.InCallback())
cbpTabStrip.PerformCallback();
}
function OnBeginCallback(s, e) {
alert('begin');
e.customArgs["Id"] = testId;
testId = null;
}
function OnEndCallback(s, e) {
alert('end');
if (testId != null)
cbpTabStrip.PerformCallback();
}
</script>
@Html.DevExpress().Button(settings => {
settings.Name = "CallbackButton";
settings.Text = "Callback";
settings.ClientSideEvents.Click = "ButtonClicked";
}).GetHtml()
@Html.Partial("CallbackTestPanel")
控制器(HomeController.cs):
public ActionResult CallbackTest()
{
return View();
}
public ActionResult CallbackTestPanel()
{
int id = !String.IsNullOrEmpty(Request.Params["Id"]) ? int.Parse(Request.Params["Id"]) : 0;
return PartialView("CallbackTestPanel");
}
附加信息:另外,我尝试根据其他在线建议更新 web.config 中的 DevExpress 配置。具体来说 - 将压缩元素上的 enableResourceMerging 属性更新为 false 而不是 true。这似乎允许回调间歇性地结束。我真的不想禁用资源合并,所以我很高兴这没有提供可靠的解决方案。所以,这就是我目前拥有的:
<devExpress>
<themes enableThemesAssembly="true" styleSheetTheme="" theme="Office2010Silver" />
<compression enableHtmlCompression="true"
enableCallbackCompression="true"
enableResourceCompression="true"
enableResourceMerging="true" />
<settings rightToLeft="false" />
<errors callbackErrorRedirectUrl="" />
</devExpress>