Slick Grid wrapped in directive (angular), some options not work (resize and drag&drop columns)

白昼怎懂夜的黑 提交于 2019-12-20 17:19:46

问题


When I've wrapped Slick Grid plugin into directive, some Slick Grid options (resizing and drag & drop columns) do not work. I think those events may conflict with directive. Does anyone have any insight?

my html:

<div style="width:600px;height:500px;" s-grid></div>

my directive:

angular.module('slickGrid.directive', [])
.directive('sGrid', [function () {
    return {
        restrict: 'EA',
        link : function(scope, element, attrs){
            // for clearer present I initialize data right in directive
            // start init data
            var columns = [
                {id: "title", name: "Title", field: "title"},
                {id: "duration", name: "Duration", field: "duration"},
                {id: "%", name: "% Complete", field: "percentComplete"},
                {id: "start", name: "Start", field: "start"},
                {id: "finish", name: "Finish", field: "finish"},
                {id: "effort-driven", name: "Effort Driven", field: "effortDriven"}
            ];
            var options = {
                enableCellNavigation: true,
                enableColumnReorder: true
            };
            var data = [];
            for (var i = 0; i < 50000; i++) {
                var d = (data[i] = {});

                d["id"] = "id_" + i;
                d["num"] = i;
                d["title"] = "Task " + i;
                d["duration"] = "5 days";
                d["percentComplete"] = Math.round(Math.random() * 100);
                d["start"] = "01/01/2009";
                d["finish"] = "01/05/2009";
                d["effortDriven"] = (i % 5 == 0);
            }
            // end init data

            // finally render layout
            scope.grid = new Slick.Grid(element, data, columns, options);
        }
    }
}]);

回答1:


my bugs are solved, after take some time to research, I found a solution here Uncaught TypeError: Cannot read property 'msie' of undefined

My newer version jquery(1.9.1) caused that problem.




回答2:


You need to include jQuery UI to use SlickGrid's column resizing/reordering.



来源:https://stackoverflow.com/questions/18246263/slick-grid-wrapped-in-directive-angular-some-options-not-work-resize-and-dra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!