Angular框架內(nèi)使用GridManager

@拭目以待:首發(fā)于Angular框架內(nèi)使用GridManager

GridManager- github地址是原生實(shí)現(xiàn),不依賴任何框架。那么在Angular框架中如何將其便捷的使用?

直接粘一個(gè)demo示例

HTML

<body ng-app="myApp">
<div ng-controller="gm">
<angular-grid-manager
option="option"
></angular-grid-manager>
</div>
</body>

JavaScript

var app = angular.module("myApp", []);
app.controller('gm', function($scope){
    // 配置GridManager init 必要參數(shù)
    var colData = [{
        key: 'name',
        remind: 'the name',
        width: '100px',
        text: '名稱',
        sorting: ''
    },{
        key: 'info',
        remind: 'the info',
        text: '使用說明'
    },{
        key: 'url',
        remind: 'the url',
        text: 'url'
    },{
        key: 'createDate',
        remind: 'the createDate',
        width: '100px',
        text: '創(chuàng)建時(shí)間',
        sorting: 'DESC',
        template: function(createDate, rowObject){
            return new Date(createDate);
        }
    },{
        key: 'lastDate',
        remind: 'the lastDate',
        width: '100px',
        text: '最后修改時(shí)間',
        sorting: '',
        template: function(lastDate, rowObject){
            return new Date(lastDate);
        }
    },{
        key: 'action',
        remind: 'the action',
        width: '100px',
        text: '操作',
        template: function(action, rowObject){
            return '<span class="plugin-action edit-action" learnLink-id="'+rowObject.id+'">編輯</span>'
                    +'<span class="plugin-action del-action" learnLink-id="'+rowObject.id+'">刪除</span>';
        }
    }];
    var queryInfo = {pluginId: 1};
    $scope.option = {
        gridManagerName: 'testAngular',
        height: '400px',
        columnData: colData,
        supportRemind: true,
        isCombSorting:  true,
        supportAjaxPage: true,
        supportSorting: true,
        ajax_url: 'http://www.lovejavascript.com/learnLinkManager/getLearnLinkList',
        ajax_type: 'POST',
        query: queryInfo,
        pageSize: 20,
        ajax_success: function(){
            console.log(arguments);
        },
        pagingAfter: function () {
            console.log('pagingAfter');
        }
    };
});
 
// 添加一個(gè)指令
app.directive("angularGridManager", function() {
    return {
        restrict : 'E',
        scope: {
            option: '='
        },
        template : '<table></table>',
        compile: function(element, arg){
            return function($scope){
                var table = element[0].querySelector('angular-grid-manager table');
                table.GM($scope.option);
            }
        }
    };
});

@拭目以待

個(gè)人站點(diǎn):www.lovejavascript.com
表格管理插件:gridmanager.lovejavascript.com && github地址
QQ交流群 (452781895):How To Make Love
微信公眾賬號(hào):loveJavascript

《野生前端工程師》專輯中所有文章均為@拭目以待 原創(chuàng),轉(zhuǎn)載請(qǐng)注明出處。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容