【问题标题】:Devextreme JS DXGrid how to call cellTemplate in code behindDevextreme JS DXGrid如何在后面的代码中调用cellTemplate
【发布时间】:2016-04-14 10:36:50
【问题描述】:

我正在尝试在后面的代码中调用 cellTemplate 函数,但我无法调用。有没有办法从后面的代码中调用这个函数?我已经尝试过,如下所示,但行显示“ShowButton”

ListDxColum.Add(new DxColumns(){
                        dataField = "cor_ref",
                        caption = "",
                        allowFiltering = false,
                        cellTemplate = "ShowButton"

                    });

JAVASCRIPT

   var orders = rec.documentList;
        $("#gridContainer").dxDataGrid({
            dataSource: {
                store: {
                    type: "array",
                    key: "ID",
                    data: orders
                }
            },
            paging: {
                pageSize: 8
            },

            showRowLines: true,
            showBorders: true,
            selection: {
                mode: "single"
            },
            filterRow: { visible: true },
            //searchPanel: {
            //    visible: true
            //},
            columns: rec.DxColumHeader,
            paging: { pageSize: 6 },
            wordWrapEnabled: true,
            filterRow: { visible: false },
            columnAutoWidth: false
        });

    function ShowButton(container, options) {
        console.log(options.data["cor_ref"]);

    }

【问题讨论】:

  • 据我了解,code behind 是服务器端的 c# 代码,不是吗?如果是这样,则无法从 c# 调用客户端 devextreme 代码。
  • 是的,它是 c# 中的服务器端。谢谢您通知我

标签: asp.net devextreme


【解决方案1】:

您可以使用此代码:

var orders = rec.documentList;
       var grid = $("#gridContainer").dxDataGrid({
            dataSource: {
                store: {
                    type: "array",
                    key: "ID",
                    data: orders
                }
            },
            paging: {
                pageSize: 8
            },

            showRowLines: true,
            showBorders: true,
            selection: {
                mode: "single"
            },
            filterRow: { visible: true },
            //searchPanel: {
            //    visible: true
            //},
            columns: rec.DxColumHeader,
            paging: { pageSize: 6 },
            wordWrapEnabled: true,
            filterRow: { visible: false },
            columnAutoWidth: false,
            cellTemplate: function (container, options) {
                console.log(options.data["cor_ref"]);
            }
        }).dxDataGrid('instance');

【讨论】:

    猜你喜欢
    • 2011-09-15
    • 2021-12-21
    • 2015-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-13
    • 1970-01-01
    相关资源
    最近更新 更多