如何解决在 Kendo-UI 向导 ASP.NET Core 中,如何通过单击从服务器获取数据?
如何向我的 razor 页面方法提交异步/ajax 调用或在向导的步骤中进行自定义验证?
例如:我想根据上一步输入的内容填充每个步骤中的数据。我查看了示例,但它们似乎没有显示此类用例。
从 documentation samples 中,显示了事件,但不清楚如何将步骤的特定完成(单击下一步)绑定到特定事件函数(以标签助手格式)。
.Events(events =>
{
events.Activate("onActivate");
events.Error("onError");
events.Done("onDone");
events.Select("onSelect");
events.Reset("onReset");
events.ContentLoad("onContentLoad");
events.FormValidateFailed("onFormValidateFailed");
})
使用标签助手并试图找出如何绑定到步骤的事件时的屏幕截图:
解决方法
事件与向导的步骤无关 - 它们处于向导级别:
<kendo-wizard name="wizard" on-activate="onActivate" on-select="onSelect">
<wizard-steps>
<wizard-step title="Initial step">
<wizard-step-content>
<h1>Initial step content</h1>
</wizard-step-content>
</wizard-step>
<wizard-step title="Second step">
<wizard-step-content>
<h1>Second step content</h1>
</wizard-step-content>
</wizard-step>
<wizard-step title="Final step">
<wizard-step-content>
<h1>Final step content</h1>
</wizard-step-content>
</wizard-step>
</wizard-steps>
</kendo-wizard>
<script>
function onActivate(e) {
console.log("Activated: " + e.step.options.label);
switch (e.step.options.label) {
case 'step 1':
//do what you need to here
break;
}
case 'step 2':
//do step 2 stuff here
$.ajax({ whatever });
break;
default:
}
}
function onSelect(e) {
console.log("Selected: " + e.step.options.label);
}
然后,在事件处理函数中 - 您可以根据触发事件的步骤来确定您想要做什么 - 使用 e.step.options.label(或那里的其他属性)。从位于 https://demos.telerik.com/aspnet-core/wizard/events 的示例中,它们输出触发每个事件的步骤的标题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。