UNPKG

angular-masterrow

Version:

The plugin necessary to use MasterRow tool in AngularJS.

175 lines (144 loc) 3.23 kB
// Angular project test var angularTestProject = angular.module('projectTestApp', ['angular-masterrow']); // Angular scope test angularTestProject.controller ('controllerTest', [ '$scope', 'angularMasterrowService', function( scope, updateService ){ scope.appFilters = { columnFilters: [ { column: 'Name', autoComplete: function (fieldValue, callback){ var interv = setInterval( function(){ callback([ 'Amos', 'Walter', 'Kempo' ]) ; clearInterval(interv); }, 3000); return [ 'Amos', 'Walter', 'Kempo', 'Amos', 'Walter', 'Kempo', 'Amos', 'Walter', 'Kempo', 'Amos', 'Walter', 'Kempo' ] } }, { column: 'ID', select: [ { name: 'Malckon', value: 1 }, { name: 'jansen', value: 2, /*selected: true*/ }, { name: 'Tibet', value: 3 } ] }, { column: 'Country' } ] }, scope.appPagination = { registerPerPage: 5 }; scope.appDetailing = { columnsToShow: ['ID', 'Date Ini', 'Name', 'Country'], // What columns (by it name), from the entire data, must be show }, scope.appPersonalization = { columnRename: [{ column: 'ID', newColumnName: "Bird Code" }] }; scope.appSorting = { enabled: true }; scope.appExporting = { exportAllPages: true } var processFunction = function (processParameters){ console.log('Sorting', processParameters.sorting); dataToGenerate = { data: { columns: ['ID', 'Date Ini', 'Date End', 'Name', 'E-Mail', 'City', 'Country'], rows: [ ['1', '12/01/1988', '12/05/2001', 'Amos Batista', 'amos.silva@gmail.com', 'São Paulo', 'Brazil'], ['2', '12/01/1988', '12/05/2001', 'Walter Red', 'walter@yep.us', 'Montgomery', 'USA'], ['3', '12/01/1988', '12/05/2001', 'Kempo Horata', 'hk@jun.jp', 'Wakkanai','Japan'], ] } }; return { data: dataToGenerate.data, metadata: { maxPages: 5, currentPage: 1 } } ; }; /* Second table */ scope.appFilters2 ={ columnFilters: [ { column: 'ID', } ] }, scope.appPagination2 = { registerPerPage: 5 }; scope.appDetailing2 = { columnsToShow: ['ID', 'Date End'], // What columns (by it name), from the entire data, must be show }, scope.appExporting2 = { exportAllPages: true } scope.appProcess2 = function (processParameters){ console.log('Sorting', processParameters.sorting); dataToGenerate = { data: { columns: ['ID', 'Date Ini', 'Date End', 'Name', 'E-Mail', 'City', 'Country'], rows: [ ['4', '12/01/1988', '12/05/2001', 'Amos Batista', 'amos.silva@gmail.com', 'São Paulo', 'Brazil'], ['5', '12/01/1988', '12/05/2001', 'Walter Red', 'walter@yep.us', 'Montgomery', 'USA'], ['6', '12/01/1988', '12/05/2001', 'Kempo Horata', 'hk@jun.jp', 'Wakkanai','Japan'], ] } }; return { data: dataToGenerate.data, metadata: { maxPages: 5, currentPage: 1 } } ; }; scope.appProcess = processFunction; scope.generateNewData = function(){ scope.$broadcast("$locationChangeSuccess"); } }]);