首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ShieldUI网格多个CustomEditors

ShieldUI网格多个CustomEditors
EN

Stack Overflow用户
提问于 2018-03-27 00:08:42
回答 1查看 58关注 0票数 1

我想知道是否有人在同一页面上使用过两个或更多的shieldui网格自定义编辑器。这将如何与getCustomEditorValue函数一起工作(使用他们常用的示例进行更新)?我猜我需要在getCustomEditorValue函数内部做些什么来区分这两个dropdowns?

代码语言:javascript
复制
$("#grid1").shieldGrid({
dataSource: {
data: products,
schema: {
    fields: {
        id: { path: "ProductID", type: Number},
        name: { path: "ProductName", type: String, nullable: false },
        quantity: { path: "SupplierID", type: Number },
        price: { path: "UnitPrice", type: Number },
        price2: { path: "UnitPrice2", type: Number },
        units: { path: "UnitsInStock", type: Number },
        discontinued: { path: "Discontinued", type: Boolean },
        myDate: { path: "d", type: Date }}}
      },
events: {
editorCreating: function(e) {
    if (e.field == "price") {
        e.options = { max: 50 };
    }
}
},
rowHover: false,
columns: [
{ field: "id" },
{ field: "name", width: "200px" },
{ field: "quantity" },
{ field: "price", editor: myCustomEditor },
{ field: "price2", editor: myCustomEditor2 },
{ field: "units" },
{ field: "discontinued" },
    { field: "myDate", format: "{0:MM/dd/yyyy}" }
],
events: {
    getCustomEditorValue: function (e) {
        e.value = $("#test").swidget().value();
        $("#test").swidget().destroy();
    }
},
editing: {
enabled: true,
event: "doubleclick
type: "cell"
}
});
function myCustomEditor(cell, item) {
$('<div id="test"/>')
    .appendTo(cell)
    .shieldDropDown({
        dataSource: {
            data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
        },
        value: !item["price"] ? null : item["price"].toString()
    }).swidget().focus();
}
function myCustomEditor2(cell, item) {
$('<div id="test2"/>')
    .appendTo(cell)
    .shieldDropDown({
        dataSource: {
            data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
        },
        value: !item["price2"] ? null : item["price2"].toString()
    }).swidget().focus();
}
EN

回答 1

Stack Overflow用户

发布于 2018-03-27 03:06:04

感谢对答案的支持:

代码语言:javascript
复制
    getCustomEditorValue: function (e) {                        
                    if ($("#dropdown1").length > 0) {
                        e.value = $("#dropdown1").swidget().value();
                        $("#dropdown1").swidget().destroy();
                    }

                    if ($("#dropdown2").length > 0) {
                        e.value = $("#dropdown2").swidget().value();
                        $("#dropdown2").swidget().destroy();
                    }
                }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49495936

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档