【问题标题】:Angular Directive in dynamic kendo table column template动态剑道表列模板中的角度指令
【发布时间】:2017-05-17 05:53:05
【问题描述】:

我有一个在角度控制器上创建的动态剑道桌, 该表是在点击事件后创建的, 在某些表格列中有角度指令。 指令未编译,模板不起作用,我得到空白单元格。 代码:

   $("#grid" + index).kendoGrid({
    dataSource: {
        transport: {
            read: {
                url: context.param.url.GetData(),
                type: "post",
                dataType: "json",
                data:
                    function () {
                        return {
                            FromDate: obj.CalcDate,
                            ToDate: obj.CalcDate,

                        }
                    }
            }
        },
        schema: {
            data: "Data",
            total: "Total"
        },
        pageSize: 5,
        serverPaging: true,
        serverSorting: true,
        serverFiltering: true
    },
    scrollable: false,
    sortable: true,
    pageable: true,

    columns: [

       {
           field: "AgregationProgramSum",
           title: resource["Productivity_Company_GridAgregationProgramSum"],
           template: "<div custom-directive=#: AgregationProgramSum # ></div>"
       },

    ]
    });

我在 chorme 调试器中看到这些值很好。 bur指令没有发生

【问题讨论】:

    标签: angularjs kendo-ui kendo-grid


    【解决方案1】:

    您的指令的代码在哪里?你应该只需要在你的网格模板中“使用”你的指令。

    这是我的指令:

         angular.module("KendoDemos")
            .directive('myDirective', function($compile) {
      return {
        restrict: 'E',
        scope: {
          list: '='
        },
        template: '<div ng-repeat="item in list">{{item.name}}</div>',
    
        replace: true,
        //require: 'ngModel',
        link: function($scope, elem, attr, ctrl) {
    
        }
      };
    });
    

    这是我使用指令的网格列:

                    columns: [{
                    field: "FirstName",
                    title: "First Name",
                    width: "120px"
                    },{
                    field: "LastName",
                    title: "Last Name",
                    width: "120px"
                    },{
                    field: "Country",
                    width: "120px",
                      hidden: true
                    },{
                    field: "City",
                    width: "120px"
                    },{
                    field: "Title",
                      template:  "<my-directive data-list='paint'></my-directive>"
    
                }],
    

    这里正在工作Dojo。也许您的指令有问题。实际看到您的代码很难说。希望这会有所帮助。

    【讨论】:

    • 感谢您的回答,但我的问题是关于页面编译后的动态模板使用。例如:仅在单击按钮时绘制的网格。谢谢!!!!!!
    猜你喜欢
    • 1970-01-01
    • 2013-11-25
    • 1970-01-01
    • 1970-01-01
    • 2016-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-13
    相关资源
    最近更新 更多