Devextreme JS DXGrid how to call cellTemplate in code behind

I'm trying call cellTemplate function in code behind but i cant call. Is there any way to call this function from code behind ? I have tried as you can see at below but the rows show "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"]);

    }

你可以使用这个代码:

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');
链接地址: http://www.djcxy.com/p/5236.html

上一篇: DevExtreme图表中同一行的样式

下一篇: Devextreme JS DXGrid如何在代码后面调用cellTemplate