You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何自定义KendoUI表格向导控件的aria-label以修复无障碍问题

解决KendoUI表格向导下拉框aria-label自定义问题

可行,你可以通过监听表格向导的open事件,定位到宽度和高度对应的下拉框元素,手动修改它们的aria-label属性,具体实现步骤如下:

  • 绑定表格向导的open事件
    在初始化Kendo编辑器的表格向导时,通过tableWizard配置项绑定open事件,示例代码如下:

    $("#editor").kendoEditor({
      tools: ["createTable"],
      tableWizard: {
        open: function(e) {
          // 在这里修改aria-label
        }
      }
    });
    
  • 定位目标下拉框并修改属性
    在open事件回调里,通过默认类名找到宽度和高度的单位下拉框,修改容器及选项的aria-label:

    open: function(e) {
      // 处理宽度单位下拉框
      const widthUnitDropdown = $(".k-table-wizard-width .k-dropdown").data("kendoDropDownList");
      if (widthUnitDropdown) {
        widthUnitDropdown.wrapper.attr("aria-label", "Width units px");
        widthUnitDropdown.items().each(function() {
          $(this).attr("aria-label", `Width units ${$(this).text()}`);
        });
      }
    
      // 处理高度单位下拉框
      const heightUnitDropdown = $(".k-table-wizard-height .k-dropdown").data("kendoDropDownList");
      if (heightUnitDropdown) {
        heightUnitDropdown.wrapper.attr("aria-label", "Height units px");
        heightUnitDropdown.items().each(function() {
          $(this).attr("aria-label", `Height units ${$(this).text()}`);
        });
      }
    }
    
  • 验证效果
    修改完成后打开表格向导弹窗,使用NVDA/JAWS测试,屏幕阅读器会读取自定义的aria-label内容。

补充说明

.k-table-wizard-width和.k-table-wizard-height是Kendo表格向导默认的区域类名,能精准定位到目标下拉框;遍历下拉选项逐个修改属性,可确保选项的读取内容与容器保持一致。

内容的提问来源于stack exchange,提问作者Nag Arjun

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 07:55:23