1.0.3 • Published 5 years ago

@mathieumaingret/responsive-table v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Responsive Table

Enable responsive layout on html tables elements

Requirements

This script requires

Installation

<link rel="stylesheet" href="../dist/responsive-table.min.css?v=0.1" media="all" />
<script src="../dist/responsive-table.min.js?v=0.1"></script>

Use

// DeviceDetect library instance
var deviceDetect = new $.DeviceDetect();
var deviceDetectDevices = deviceDetect.getDevices();

// Mandatory options
var options = {
    deviceDetect: deviceDetect,
    devices: deviceDetectDevices
};

// Init
$('#content table').responsiveTable(options);

Options

Key (* is mandatory)DescriptionDefault valueExamples
deviceDetect *Library instance, using the onResize() method for instanceundefined
devices *(object) Indicate for each available device the current one{}{desktop: true, mobile: false, tablet: false}
breakpoint(string) On which deviceDetect device the responsive layout can be appliedmobile
reloadOnResize(bool) On window resize, check current device againtrue
allowFallbackOnFirstRow(bool) If no \<thead> or \<th> tags are founded for each tables, the first \<tr> row will be used to get the table labelstrue
labelsDisplay(string) Layout to be applied. By default, 'inline' or 'block' are availableinlineinline / block
classes(object) HTML classes applied on the \<table> elementSee below

HTML Classes option

classes: {
    prefix: 'responsive-table',
    initialized: 'is-initialized',
    hasLabels: 'is-label',
    cellWrapper: 'cell-wrapper'
}

Custom Layout

The labelsDisplay simply adds an HTML class, so you can apply whatever you want, as long as you manage this layout in your css declarations.