Comments (12)
Sure, it makes sens.
I'll do it over the week end ; or you can make a pull request if you want.
Thanks
Laurent
from smart-table.
fixed with 4f6501c
from smart-table.
Did you remove that selectionChange event?
Testing version 1.3.0 and using $scope.$on('selectionChange', ... ).
No event gets fired and browsing the smart-table code for version 1.3.0 there is no sign of any event namend "selectionChange". Did you remove this feature?
from smart-table.
There is no event anymore you are correct, you can consider v1.x.x as a totally new module.
to know which item has been selected, you could watch the bound collection, or even add an handler on click if you think it could introduce performance issues. Now the scope hierarchy is much simpler and whatever you declare in the table will be in the current scope of your controller
from smart-table.
Could you please provide an example on this? As far as I understand, if you watch the bound collection, then you are going to be notified only when it changes but not when the items inside get a new property or similar.
from smart-table.
Ah, nevermind, was just too lazy to write it myself. But here it is, in case somebody needs it:
$scope.$watch('displayedCollection', function(newVal) {
console.log("selected items: " + newVal.filter(function(item) {
return item.isSelected;
}).length);
}, true);
from smart-table.
In my case it was:
$scope.$watch(function() {
return _.filter($scope.displayedElts, function (elt) { return elt.isSelected; }).length;
}, function(newValue, oldValue) {
$log.debug('Number of selected elts has change oldValue="%d" newValue="%d"', oldValue, newValue);
});
from smart-table.
It doesn't work for 2.1.3:
$scope.$watch('displayedCollection', function(newVal) {
console.log("selected items: " + newVal.filter(function(item) {
return item.isSelected;
}).length);
}, true);
It seems Angular can't see changes any longer for bound collections.
from smart-table.
I am having the same issue when trying to send a selected row to a new table in a bootstrap modal.
I'm putting a watch on the collection, but it is not keeping track of anything. I also put a second function in ng-click, and pass the row as a parameter to a function but the function does not get called.
//Here's the markup
<tr ng-click="row.isSelected = !row.isSelected; test(a)" ng-class="{'st-selected':row.isSelected}" st-selected-row="row" st-select-mode="multiple"
ng-repeat="a in smertAccountTabe" ng-show="!acc.isloading">
//here are the functions in the controllers
$scope.test = function () {
//no dialog popping up
alert("test worked on click");
}
$scope.$watch('smertAccountTabe', function (row) {
//get selected row
//alert("test this filter");
row.filter(function (r) {
if (r.isSelected) {
alert("test the watch");
console.log(r);
return r;
}
})
}, true);
//here is the CSS for row selection
.table-striped>tbody>tr.st-selected:nth-child(odd)>td,
.table-striped>tbody>tr.st-selected:nth-child(even)>td {
background-color: #001A67 !important;
color: #fefefe!important;
}
from smart-table.
Has anyone found a solution for this?
from smart-table.
@KavyaShetty This snippet does the trick for me:
$scope.$watch(function() {
return _.filter($scope.displayedElts, function (elt) { return elt.isSelected; }).length;
}, function(newValue, oldValue) {
$log.debug('Number of selected elts has change oldValue="%d" newValue="%d"', oldValue, newValue);
});
from smart-table.
Hey Ya'll anyone can help me? I've been trying this and it works but errors in browser console this, "Error: row is undefined".
$scope.$watch('displayedCollection', function(row) {
// get selected row
row.filter(function(r) {
if (r.isSelected) {
console.log(r);
}
})
}, true);
from smart-table.
Related Issues (20)
- Natural sort of alpha numeric string HOT 1
- st-sort-default="true" is not working fine with custom sort HOT 6
- st-ratio can not be declared as a function HOT 1
- st-sort-default="true" not working when table first loads. HOT 2
- Delete row after searching HOT 1
- When I debug st-table safeCopy object it returns empty array. HOT 1
- sever side pagination
- Paginated data updates HOT 1
- Angularjs plugin smart table st-search through random text entered like datatablejs search HOT 7
- get filter date in table using start and end date in angular 5 HOT 1
- Smart table with two custom date filters HOT 1
- Virtualisation feature
- Manipulate the current page within a controller for pagination
- Serverside pagination issue
- Smart table documentation website melts my computer HOT 1
- aria-sort order is wrong
- Question: how to programmatically go to a specific page?
- Custom filtering on single column HOT 1
- How to pass argument with st-pipe
- st-sort does not work when start with number.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smart-table.