vue.js - 如何在剑道网格自定义编辑器中添加 vue 组件?
问题描述
我有一列剑道网格,例如:
<kendo-grid-column
:field="'qrcode'"
:title="'qrcode'"
:width="200"
:editor="qrcodeEditor"
></kendo-grid-column>
根据Setting Custom Editors,我可以将编辑器重写为textarea
, checkbox
, 或dropdown list
, 像
textareaEditor: function(container, options) {
$('<textarea data-bind="value: ' +
options.field +
'" cols="20" rows="4"></textarea>'
).appendTo(container);
},
我的问题是如果编辑器是一个 vue 组件,比如<qrcode-capture />怎么办?
解决方案
我找到了解决方案:
methods:{
qrcodeEditor: function(container, options) {
// An <input> element is required for binding data
let input = $(`<input data-bind="value:${options.field}" class="k-textbox width-50"/>`);
input.appendTo(container);
// use Vue.extend to make a component constructor, and new a component
let qrcodeCapture = new (Vue.extend(QrcodeCapture))();
qrcodeCapture.$on("decode", decodedString => {
input.val(decodedString).trigger("change");
// Trigger "change" element to tell kendo that you have change the data
});
qrcodeCapture.$mount();
container.append(qrcodeCapture.$el);
},
}
推荐阅读
- c++ - 这种对共享指针向量的回退是否会导致内存泄漏?
- android - kotlin 中 RecyclerView 内的 RecyclerView
- php - 无法修复 404 NOT FOUND 错误,因为我无法查看和访问 Elastic beanstalk 创建的 ec2 中的文件
- powershell - Power BI 部署管道 - 通过 API 比较功能
- angular - ngrx 效果:期望两个动作都完成
- android-studio - 如何保存深层链接的参数
- git - 在 git rebase -i 中只使用一个提交评论
- c - 我如何知道哪些 AVX C 功能可用于不同的处理器型号
- typescript - 从泛型函数推断真实类型
- mysql - 在 phpmyadmin 的 mysql 数据库中添加复合键时出错