npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ion-dynamic-tree-list

v0.0.12

Published

Ionic directive for displaying nested list items.

Downloads

2

Readme

ion-dynamic-tree-list

Code Climate

Ionic directive for displaying nested list ionic items. This project is modified from ion-tree-list. While ion-tree-list is perfectly ok, it takes a while to load 1000+ nodes. I had an application that needed to handle this load and after a little research, the two way binding of Angular JS was the culprit. I decided to re-write it and load the subtree only when it is opened by the user. It results a faster rendering time. I decided to rename it to ion-dynamic-tree-list since the usage is quite different and it worked for me and hopefully, someone else will find it useful.

Installation

bower install ion-dynamic-tree-list --save

Add somewhere in your HEAD tag:

<script src="lib/ion-dynamic-tree-list/ion-dynamic-tree-list.js"></script>

You'll need to add ion-dynamic-tree-list as a dependency on your Ionic app:

angular.module('starter', [
    'ionic', 
    'controllers', 
    'services', 
    'ion-dynamic-tree-list'
])

In your controller.js:

  $scope.tasks = [{id: 1, parentid: 0, name: 'task 1'},
    {id: 2, parentid: 1, name: 'task 1.1'},
    {id: 3, parentid: 0, name: 'task 2'},
    {id: 4, parentid: 0, name: 'task 3'}
   ];

Or, you could load your $scope.tasks from database, e.g.:

Assuming your table structure is:

| Column | Type | | ------------- |:-------------:| | id | int | | parentid | int | | name | varchar(40) |

Note that the display order of an element follows the position of it in the array. So, you need to use "order by" in your database statement to control the display order of the tree.

    $http.get('http://yourwebsite/GetTasks').
       then(function (response) {
           $scope.tasks = response.data;
        });

In your view.html:

<ion-dynamic-tree-list items="" source="tasks"></ion-dynamic-tree-list>

Fetch clicked item by listening to $ionDynamicTreeList:ItemChosen in your controller:

Emmited events

$scope.$on('$ionDynamicTreeList:ItemChosen', function(event, item) {
  // process 'item'
  console.log(item);
});

Custom templates

Imagine your tasks in $scope.tasks in your controller.js has an extra attribute as checked:

  $scope.tasks = [{id: 1, parentid: 0, name: 'task 1', checked: false},
      {id: 2, parentid: 1, name: 'task 1.1', checked: false},
      {id: 3, parentid: 0, name: 'task 2', checked: true},
      {id: 4, parentid: 0, name: 'task 3', checked: false}
     ];

In order to consume the checked value in your view, create a ion-item.tmpl.html file in your www folder containing the following:

<input type="checkbox" ng-model="item.checked"/>
{{item.name}}

Add an extra template-url attribute for your custom template:

<ion-dynamic-tree-list items="" source="tasks" template-url="'ion-item.tmpl.html'"></ion-dynamic-tree-list>

Contributing

If you need a fix, please report your issue in here.

Code contribution is always welcomed.

Acknowledgment

Forked from ion-tree-list in here

To-dos

  • Angular JS 2! Waiting for Ionic 2 to finalize.
  • More complete Unit Test in Jasmine.
  • Combine "items" and "source" into one?
  • Add additional emit event when a tree is being collapse/expand for easier change by a developer?