Skip to content

useCheckboxes

This composable supports selecting checkboxes in tables. It operates on an object that contains information for the selector selecting actions to be performed on selected checkboxes:

  • countAll: counter of all records
  • countPage: record counter per page
  • markAll: whether all have marked
  • type: chosen - selected, all - all
  • items: array of ids of selected items, for type all it is always empty
  • types: array of types/actions - can be changed in the view

Metody

The following methods(functions) are available:

  • toggle(id: number) - checks/unchecks the checkbox, adding it to the selected list
  • toggleAll(arr: Array<Item>) - selects all checkboxes on the page
  • toggleType(arr: Array<Item>, type: string) - selects all checkboxes of the selected type on the page
  • inList(id: number) - checks whether the record with a specific id is on the selected list
  • setLimit(limit: number) - sets the checkbox counter per page
  • totalChecked() - returns a counter of all available records
  • setTotal(total: number) - sets the counter of all available records
  • isAll() - checks whether the selection type covers all records on the page
  • isIndeterminate() - checks if any records are selected
  • getType() - returns the type of selected records
  • setType(type: string) - sets the type of selected records
  • getMarkAll() - returns information about whether the selection includes all available records
  • setMarkAll(markAll: boolean) - sets information about whether the selection includes all available records
  • getTypes() - returns a list of available types
  • setTypes(types: Array<string>) - adds an array of available types
  • getForAction() - returns an object with data needed to perform the operation (e.g. change/delete)