Skip to content

Commit

Permalink
add onEdit event with lastValue and newValue params
Browse files Browse the repository at this point in the history
  • Loading branch information
ekokotov committed Jan 22, 2016
1 parent c7bd6d6 commit e159785
Show file tree
Hide file tree
Showing 5 changed files with 439 additions and 460 deletions.
150 changes: 75 additions & 75 deletions dev/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,103 +4,103 @@
* gTableTest Description
*/
angular.module('test', ['objectTable'])
.controller('mainController', function ($scope,$http,$timeout,$q) {


$scope.data = [{name: "Moroni", age: 50, money: -10},
{name: "Tiancum", age: 43,money: 120},
{name: "Jacob", age: 27, money: 5.5},
{name: "Nephi", age: 29,money: -54},
{name: "Enos", age: 34,money: 110},
{name: "Tiancum", age: 43, money: 1000},
{name: "Jacob", age: 27,money: -201},
{name: "Nephi", age: 29, money: 100},
{name: "Enos", age: 34, money: -52.5},
{name: "Tiancum", age: 43, money: 52.1},
{name: "Jacob", age: 27, money: 110},
{name: "Nephi", age: 29, money: -55},
{name: "Enos", age: 34, money: 551},
{name: "Tiancum", age: 43, money: -1410},
{name: "Jacob", age: 27, money: 410},
{name: "Nephi", age: 29, money: 100},
{name: "Enos", age: 34, money: -100}];

$scope.test = function(e) {
alert('Alert from controller method!');
.controller('mainController', function($scope, $http, $timeout, $q) {

$scope.data = [{name: 'Moroni', age: 50, money: -10},
{name: 'Tiancum', age: 43,money: 120},
{name: 'Jacob', age: 27, money: 5.5},
{name: 'Nephi', age: 29,money: -54},
{name: 'Enos', age: 34,money: 110},
{name: 'Tiancum', age: 43, money: 1000},
{name: 'Jacob', age: 27,money: -201},
{name: 'Nephi', age: 29, money: 100},
{name: 'Enos', age: 34, money: -52.5},
{name: 'Tiancum', age: 43, money: 52.1},
{name: 'Jacob', age: 27, money: 110},
{name: 'Nephi', age: 29, money: -55},
{name: 'Enos', age: 34, money: 551},
{name: 'Tiancum', age: 43, money: -1410},
{name: 'Jacob', age: 27, money: 410},
{name: 'Nephi', age: 29, money: 100},
{name: 'Enos', age: 34, money: -100}];

$scope.test = function(e) {
alert('Alert from controller method!');
};

$scope.logChange = function(oldValue, newValue) {
console.log(oldValue);
console.log(newValue);
};

$scope.dataTeacherSearch = [{"employeeNo":"4433",
"name":{"firstName":"kuldeep","middleName":"dsf","lastName":"gfdkjh"},
"department":[{"dept":"Computer Science","status":true},
{"dept":"science","status":false},
{"dept":"sports","status":false},
{"dept":"sdlkf","status":false}],
"designation":[{"post":"director","status":false},
{"post":"principal","status":false},
{"post":"teaching","status":true},
{"post":"nonteaching","status":false}]}];
$scope.dataTeacherSearch = [{'employeeNo': '4433',
'name': {'firstName': 'kuldeep','middleName': 'dsf','lastName': 'gfdkjh'},
'department': [{'dept': 'Computer Science','status': true},
{'dept': 'science','status': false},
{'dept': 'sports','status': false},
{'dept': 'sdlkf','status': false}],
'designation': [{'post': 'director','status': false},
{'post': 'principal','status': false},
{'post': 'teaching','status': true},
{'post': 'nonteaching','status': false}]}];

$scope.report = {
selectedUser:null
}


$scope.pagingExample = {
exData:null,
limit:0,
currentPage:0,
total:0,
pages:[]
};
selectedUser: null
}

$scope.pagingExample = {
exData: null,
limit: 0,
currentPage: 0,
total: 0,
pages: []
};

var ctrl = this,
initialLoaded=false;
var ctrl = this,
initialLoaded = false;

$scope.loadData = function(n){
$scope.loadData = function(n) {

//don't load if n==0 or n>pages
if($scope.pagingExample.pages.length){
if(n==0 || n > $scope.pagingExample.pages.length) return;
if ($scope.pagingExample.pages.length) {
if (n == 0 || n > $scope.pagingExample.pages.length) return;
};

//load data
$http.get('data/data-page'+ n +'.json').then(function(response){
$scope.pagingExample.exData = response.data.data;
$scope.pagingExample.limit = response.data.limit;
$scope.pagingExample.currentPage = response.data.page;
$scope.pagingExample.total = response.data.total;

//calculate pages just once - after first loading
if(!initialLoaded){
ctrl.getTotalPages();
initialLoaded = true;
};
$http.get('data/data-page' + n + '.json').then(function(response) {
$scope.pagingExample.exData = response.data.data;
$scope.pagingExample.limit = response.data.limit;
$scope.pagingExample.currentPage = response.data.page;
$scope.pagingExample.total = response.data.total;

//calculate pages just once - after first loading
if (!initialLoaded) {
ctrl.getTotalPages();
initialLoaded = true;
};
});
};
};

// load first page
$scope.loadData($scope.pagingExample.currentPage+1);
// load first page
$scope.loadData($scope.pagingExample.currentPage + 1);

// calculate totals and return page range ([1,2,3])
this.getTotalPages = function(){
// calculate totals and return page range ([1,2,3])
this.getTotalPages = function() {
var count = Math.round($scope.pagingExample.total / $scope.pagingExample.limit);
for (var i = 0; i < count; i++) {
$scope.pagingExample.pages.push(i);
$scope.pagingExample.pages.push(i);
};
};
};

$scope.getTotalBalance = function(data){
if(!data || !data.length) return;
$scope.getTotalBalance = function(data) {
if (!data || !data.length) return;
var totalNumber = 0;
for(var i=0; i<data.length; i++){
for (var i = 0; i < data.length; i++) {
totalNumber = totalNumber + parseFloat(data[i].money);
}

return Math.round(totalNumber);

};


};

})
})
Loading

0 comments on commit e159785

Please sign in to comment.