WireBootstrap
HomeDocsBuySupport
  • Introduction
  • Overview
  • Getting Started
  • Installation
  • Connecting to Data
    • Data Connectors
      • SQL Data
      • Custom Web Services
      • Local Data
      • Other Sources
    • Data Sources
    • Discovery
    • Building a Data Connector
  • Working With Queries
    • Select Queries
      • Query Extensions
    • Stored Procedures
    • Custom Web Services
    • Executing Queries
    • ORM
  • Writing Data
  • Updates
  • Deletes
  • Working with DataTables
    • Introduction
    • Filter and Sort
    • Select and Calculate
    • Joins
    • Rows
    • Columns
  • Working with DataSets
  • Introduction
  • Executing Queries
  • Transforms
  • Writing Data
  • Data Events
  • Working with Components
    • Introduction
    • Encapsulation
    • Configuration
      • Data
      • Events
      • Observables
      • Validation
      • Display
      • Vendor
      • Custom
    • Component
    • Web Frameworks
    • Building a Component
      • Hello World
      • Data Events
      • DataSets
  • Working With Data Events
    • Introduction
    • Event Basics
    • Event Data
    • Event Actions
  • Working with Themes
    • Introduction
    • Sample Data
    • Libraries
    • Pages
    • Building a Theme Project
  • Utilities
    • Formatting
    • Expressions
    • Collections
    • Spinners
    • Copy and Merge
    • Validation
    • Loading Assets
    • Service Calls
    • Download Files
    • Browser Location
    • Types
    • Promise
  • Reference
    • wire
      • wire.Collection
      • wire.download
      • wire.validate
    • wire.data
      • wire.data.DataEvent
      • wire.data.DataModel
      • wire.data.DataPromise
      • wire.data.DataSet
      • wire.data.DataSource
      • wire.data.DataTable
        • Columns
        • Rows
      • wire.data.StoredProcedure
      • wire.data.TableQuery
    • wire.ui
      • wire.ui.Component
      • wire.ui.validate
Powered by GitBook
On this page
  • Create a Collection
  • Add an Object
  • Retrieve an Object
  • Remove an Object
  • Retrieve the Array

Was this helpful?

  1. Utilities

Collections

WireBootstrap collections allow an array of objects to be managed using one of the attributes as a key.

Create a Collection

To create a collection, create a new instance of the wire.Collection class passing in the key field that makes each row unique along with the array of data.

let users = [
    { UserName: "jkratz", FullName: "Jamie Kratz", Active: true },
    { UserName: "pdougherty", FullName: "Pat Dougherty" Active: true },
    { UserName: "mchermela", FullName: "Mike Chermela", Active: false }
];

let col = new wire.Collection("UserName", users);

Add an Object

To add an object, use the set method on the collection. This method will add the object to the collection if it does not already exist. If the object exists, it will be overwritten with the object that is passed into the method.

...

const amy = { UserName: "apeters", FullName: "Amy Peters", Active: true };
    
const mike = col.set(amy);

Retrieve an Object

To pull an object out of the collection, use the get method with the key value.

...

const mike = col.get("mchermela");

Remove an Object

Use the remove method with the key to remove an object from the collection.

...

col.remove("jkratz");

Retrieve the Array

To pull the array out of the collection, use the array method.

...

const users = col.array();

PreviousExpressionsNextSpinners

Last updated 4 years ago

Was this helpful?

For more on WireBootstrap collections, visit .

wire.Collection