Coder Social home page Coder Social logo

Comments (12)

lorenzofox3 avatar lorenzofox3 commented on July 22, 2024

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.

lorenzofox3 avatar lorenzofox3 commented on July 22, 2024

fixed with 4f6501c

from smart-table.

andrenam avatar andrenam commented on July 22, 2024

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.

lorenzofox3 avatar lorenzofox3 commented on July 22, 2024

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.

antonsarov avatar antonsarov commented on July 22, 2024

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.

antonsarov avatar antonsarov commented on July 22, 2024

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.

jmcollin78 avatar jmcollin78 commented on July 22, 2024

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.

astsiapanay avatar astsiapanay commented on July 22, 2024

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.

lildukedana avatar lildukedana commented on July 22, 2024

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.

KavyaShetty avatar KavyaShetty commented on July 22, 2024

Has anyone found a solution for this?

from smart-table.

jmcollin78 avatar jmcollin78 commented on July 22, 2024

@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.

totallytotallyamazing avatar totallytotallyamazing commented on July 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.