当我将 Slick Grid 插件包装到指令中时,一些 Slick Grid 选项(调整大小和拖放列)不起作用。我认为这些事件可能与指令冲突。有没有人有任何见解?
我的html:
<div style="width:600px;height:500px;" s-grid></div>
我的指令:
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);
}
}
}]);