Skip to content

📋 Ionic app to experiment with data tables. Tutorial app from Simon Grimm of Devdactic

License

Notifications You must be signed in to change notification settings

AndrewJBateman/ionic-angular-datatables

Repository files navigation

⚡ Ionic Angular Datatables

  • App to display a responsive table of data from an API, using the Ionic framework with Angular
  • Code from Simon Grimm - see 👏 Inspiration below
  • Note: to open web links in a new window use: ctrl+click on link

GitHub repo size GitHub pull requests GitHub Repo stars GitHub last commit

📄 Table of contents

📚 General info

  • App gets data from a random user details API and displays it in a responsive table that, upon resizing, reduces the number of columns from 6 (PC screen) to 4 (mobile screen)
  • Updated to latest Ionic, Angular etc. note: tsconfig.json compiler options updated to include "skipLibCheck": true

📷 Screenshots

screen print screen print

📶 Technologies

💾 Setup

  • Load dependencies using npm i
  • To start the server on localhost://8100 type: ionic serve

💻 Code Examples

  • bulkDelete() method uses checkbox column result to remove rows checked
  // take items checked - this.edit - and filter indexes and coerce into a number
  // remove rows with this index using the splice method
  bulkDelete() {
    console.log('this.edit: ', this.edit); // example: returns {0: true, 1: true, 2: true}
    const preDelete = Object.keys(this.edit);
    console.log('preDelete', preDelete) // example returns ["0", "1", "2"] - array of strings
    const deleteList = preDelete.filter(index => this.edit[index]).map(key => +key); // [0, 1, 2]
    while (deleteList.length) { // as long as deleteList is > 0
      this.data.splice(deleteList.pop(), 1) // splice each row[item], pop deleteList down each time
    }
    this.toggleBulkEdit(); // boolean switched to hide bulkEdit ion-button once complete
  }

🆒 Features

  • Sort function uses the localeCompare() method to return a number indicating if a reference string comes before or after or is the same as the given string in sort order.
  • ion-select-option used to provide drop-down rows per page options. Couldn't work out how to have a default selected value, e.g. 10, currently defaults to the full list until a rows per page option is chosen

📋 Status & To-do list

  • Status: Working
  • To-do: Nothing

👏 Inspiration

📁 License

  • N/A

✉️ Contact