maxazan / jquery-treegrid

TreeGrid plugin for jQuery
http://maxazan.github.io/jquery-treegrid
MIT License
553 stars 222 forks source link

There's a problem about the method 'isLast'; #3

Closed uranusAdam closed 11 years ago

uranusAdam commented 11 years ago

$('.tree').find('tr').each(function(){ if ($(this).treegrid('isLast')){ $(this).find('.treegrid-expander').css("background","red"); } }); Here's my code; And this is the error from firebug TypeError: $(...).treegrid(...) is undefined

uranusAdam commented 11 years ago

The problem has been solved. isLast: function() { var current_parent_id = $(this).treegrid('getParentNodeId'); if ($(this).next().length>0) { if ($(this).next().treegrid('getParentNodeId') === current_parent_id) { return false; } else { return true; } } else { return true; } },

maxazan commented 11 years ago

Thanks for you help! Now you can use

  $('.tree').treegrid('getAllNodes').each(function() {
    if ($(this).treegrid("isLast")) {
      $(this).find('.treegrid-expander').css("background","red");
    }
  });

or

  $('.tree').find('tr').each(function() {
    if ($(this).treegrid("isNode") && $(this).treegrid("isLast")) {
      $(this).find('.treegrid-expander').css("background","red");
    }
  });