jQuery Grid Plugin Based on jQuery UI Widget Design | ParamQuery Grid

ParamQuery is a jQuery Grid plugin for displaying data in an MS Excel-like data grid with lots of options. It can also display any data source format like HTML, Array, XML, JSON, etc.ParamQuery works with the jQueryUI Widget factory and is an excellent design pattern for UI controls with a consistent API.

jquery hierarchical grid example, jquery grid plugin, jquery grid layout, paramquery grid example, jquery grid example, jquery plugin for gridview

How to make use of it:

1. Include jQuery Library, jQuery UI, and the ParamQuery Gird files on the web page.

<!-- jQuery 2.x+ -->   
<script src="/path/to/cdn/jquery.min.js"></script>

<!-- jQuery UI 1.12+ -->
<link href="/path/to/cdn/jquery-ui.css" rel="stylesheet" />
<link href="/path/to/cdn/jquery-ui.structure.css" rel="stylesheet" />
<link href="/path/to/cdn/jquery-ui.theme.css" rel="stylesheet" />
<script src="/path/to/cdn/jquery-ui.js"></script>

<!-- Core stylesheet -->
<link rel="stylesheet" href="/path/to/pqgrid.min.css" />    

<!-- For jQueryUI theme support -->
<link rel="stylesheet" href="/path/to/pqgrid.ui.min.css" />

<!-- Themes -->
<link rel="stylesheet" href="/path/to/themes/bootstrap/pqgrid.css" />
<link rel="stylesheet" href="/path/to/themes/brown/pqgrid.css" />
<link rel="stylesheet" href="/path/to/themes/chocolate/pqgrid.css" />
<link rel="stylesheet" href="/path/to/themes/cocoa/pqgrid.css" />
<link rel="stylesheet" href="/path/to/themes/crimson/pqgrid.css" />
<link rel="stylesheet" href="/path/to/themes/gray/pqgrid.css" />
<link rel="stylesheet" href="/path/to/themes/indigo/pqgrid.css" />
<link rel="stylesheet" href="/path/to/themes/Office/pqgrid.css" />
<link rel="stylesheet" href="/path/to/themes/purple/pqgrid.css" />
<link rel="stylesheet" href="/path/to/themes/red/pqgrid.css" />
<link rel="stylesheet" href="/path/to/themes/rosybrown/pqgrid.css" />
<link rel="stylesheet" href="/path/to/themes/sandybrown/pqgrid.css" />
<link rel="stylesheet" href="/path/to/themes/steelblue/pqgrid.css" />
<link rel="stylesheet" href="/path/to/themes/tan/pqgrid.css" />
<link rel="stylesheet" href="/path/to/themes/violet/pqgrid.css" />

<!-- Core JavaScript -->
<script src="/path/to/pqgrid.min.js"></script>   

<!-- Locals -->
<script src="/path/to/localize/pq-localize-de.js"></script>
<script src="/path/to/localize/pq-localize-en.js"></script>
<script src="/path/to/localize/pq-localize-es.js"></script>
<script src="/path/to/localize/pq-localize-fr.js"></script>
<script src="/path/to/localize/pq-localize-hu.js"></script>
<script src="/path/to/localize/pq-localize-it.js"></script>
<script src="/path/to/localize/pq-localize-ja.js"></script>
<script src="/path/to/localize/pq-localize-nl.js"></script>
<script src="/path/to/localize/pq-localize-pl.js"></script>
<script src="/path/to/localize/pq-localize-pt.js"></script>
<script src="/path/to/localize/pq-localize-pt-br.js"></script>
<script src="/path/to/localize/pq-localize-ru.js"></script>
<script src="/path/to/localize/pq-localize-tr.js"></script>
<script src="/path/to/localize/pq-localize-zh.js"></script>
<script src="/path/to/localize/pq-localize-zh_TW.js"></script>

<!-- For xlsx and zip export (optional)-->
<script src="/path/to/jsZip/jszip.min.js"></script>

2. You’re additionally allowed to import the ParamQuery Gird by way of NPM.

# NPM
$ npm i pqgridf --save
import pq from 'pqgridf';
@import '~jquery-ui-pack/jquery-ui.css';
@import '~jquery-ui-pack/jquery-ui.structure.css';
@import '~jquery-ui-pack/jquery-ui.theme.css';
@import '~pqgridf/pqgrid.min.css';
@import '~pqgridf/pqgrid.ui.min.css';
@import '~pqgridf/themes/steelblue/pqgrid.css';
// ...

3. Create a container to carry the info grid.

<div id="grid_array" style="margin:100px;"></div>

4. Call the plugin and populate the info grid with the information you present as follows:

$(function () {
  
  var data = [
      [1, 'Exxon Mobil', '339,938.0', '36,130.0'],
      [2, 'Wal-Mart Stores', '315,654.0', '11,231.0'],
      [3, 'Royal Dutch Shell', '306,731.0', '25,311.0'],
      [4, 'BP', '267,600.0', '22,341.0'],
      [5, 'General Motors', '192,604.0', '-10,567.0'],
      [6, 'Chevron', '189,481.0', '14,099.0'],
      [7, 'DaimlerChrysler', '186,106.3', '3,536.3'],
      [8, 'Toyota Motor', '185,805.0', '12,119.6'],
      [9, 'Ford Motor', '177,210.0', '2,024.0'],
      [10, 'ConocoPhillips', '166,683.0', '13,529.0'],
      [11, 'General Electric', '157,153.0', '16,353.0'],
      [12, 'Total', '152,360.7', '15,250.0'],
      [13, 'ING Group', '138,235.3', '8,958.9'],
      [14, 'Citigroup', '131,045.0', '24,589.0'],
      [15, 'AXA', '129,839.2', '5,186.5'],
      [16, 'Allianz', '121,406.0', '5,442.4'],
      [17, 'Volkswagen', '118,376.6', '1,391.7'],
      [18, 'Fortis', '112,351.4', '4,896.3'],
      [19, 'Crit Agricole', '110,764.6', '7,434.3'],
      [20, 'American Intl. Group', '108,905.0', '10,477.0']];

  var obj = { width: 700, height: 400, title: "ParamQuery Grid Example",resizable:true,draggable:true };
  obj.colModel = [{ title: "Rank", width: 100, dataType: "integer" },
      { title: "Company", width: 200, dataType: "string" },
      { title: "Revenues ($ millions)", width: 150, dataType: "float", align: "right" },
      { title: "Profits ($ millions)", width: 150, dataType: "float", align: "right"}];
  obj.dataModel = { data: data };
  
  $("#grid_array").pqGrid(obj);

}); 

5. All default config choices.

{
  cancel: "input,textarea,button,select,option,.pq-no-capture,.ui-resizable-handle",
  trigger: false, // emit the events to DOM nodes
  bootstrap: {
    on: false,
    thead: "table table-striped table-condensed table-bordered",
    tbody: "table table-condensed",
    grid: "panel panel-default",
    top: "",
    btn: "btn btn-default",
    groupModel: {
      icon: ["glyphicon-triangle-bottom", "glyphicon-triangle-right"]
    },
    header_active: "active"
  },
  ui: {
    on: true,
    grid: "ui-widget ui-widget-content",
    top: "ui-widget-header",
    bottom: "ui-widget-header",
    header_o: "ui-widget-header",
    header: "ui-state-default",
    header_active: "ui-state-active"
  },
  cls: {
    cont_inner: "pq-grid-cont-inner",
    cont_inner_b: "pq-grid-cont-inner-b"
  },
  distance: 3,
  collapsible: {
    on: true,
    toggle: true,
    collapsed: false,
    _collapsed: false,
    refreshAfterExpand: true,
    css: {
      zIndex: 1e3
    }
  },
  colModel: null,
  columnBorders: true,
  dataModel: {
    data: [],
    dataUF: [],
    cache: false,
    dataType: "JSON",
    location: "local",
    sorting: "local",
    sortDir: "up",
    method: "GET"
  },
  direction: "", // 'horizontal', 'vertical', 'all'
  draggable: false,
  editable: true,
  editModel: {
    cellBorderWidth: 0,
    pressToEdit: true,
    clicksToEdit: 2,
    filterKeys: true,
    keyUpDown: true,
    reInt: /^([\-]?[1-9][0-9]*|[\-]?[0-9]?)$/,
    reFloat: /^[\-]?[0-9]*\.?[0-9]*$/,
    onBlur: "validate",
    saveKey: $.ui.keyCode.ENTER,
    onSave: "nextFocus",
    onTab: "nextFocus",
    allowInvalid: false,
    invalidClass: "pq-cell-red-tr pq-has-tooltip",
    warnClass: "pq-cell-blue-tr pq-has-tooltip",
    validate: true
  },
  editor: {
    select: false,
    type: "textbox"
  },
  summaryOptions: {
    number: "avg,sum,max,min",
    date: "count,max,min",
    string: "count"
  },
  summaryTitle: {
    avg: "Avg: {0}",
    count: "Count: {0}",
    max: "Max: {0}",
    min: "Min: {0}",
    sum: "Sum: {0}"
  },
  validation: {
    icon: "ui-icon-alert",
    cls: "ui-state-error",
    style: "padding:3px 10px;"
  },
  warning: {
    icon: "ui-icon-info",
    cls: "",
    style: "padding:3px 10px;"
  },
  freezeCols: 0,
  freezeRows: 0,
  freezeBorders: true,
  calcDataIndxFromColIndx: true,
  height: 400,
  hoverMode: "null",
  _maxColWidth: "99%",
  _minColWidth: 50,
  minWidth: 100,
  numberCell: {
    width: 30,
    title: "",
    resizable: true,
    minWidth: 30,
    maxWidth: 100,
    show: true
  },
  pageModel: {
    curPage: 1,
    totalPages: 0,
    rPP: 10,
    rPPOptions: [10, 20, 50, 100]
  },
  resizable: false,
  roundCorners: true,
  rowBorders: true,
  rowHeight: 25,
  scrollModel: {
    pace: "fast",
    smooth: false,
    horizontal: true,
    lastColumn: "auto",
    autoFit: false,
    theme: true
  },
  selectionModel: {
    type: "cell",
    onTab: "nextFocus",
    row: true,
    mode: "block"
  },
  swipeModel: {
    on: true,
    speed: 20,
    ratio: .15,
    repeat: 20
  },
  showBottom: true,
  showHeader: true,
  showTitle: true,
  showToolbar: true,
  showTop: true,
  sortable: true,
  sql: false,
  stripeRows: true,
  title: "&nbsp;",
  treeModel: null,
  virtualX: false,
  virtualY: false,
  width: "auto",
  wrap: true,
  hwrap: true
}; 

6. API strategies.

// add additional CSS class(es)
.addClass({ rowData, rowIndx, dataIndx, class, refresh });

// add more row(s)
.addRow({ newRow, rowIndx, rowList, track, source, history, checkEditable, refresh });

// get the value of an attribute
.attr({ rowData, rowIndx, dataIndx, attr });

// collapse the grid
.collapse();

// expand the grid
.expand();

// accept or commit the add, edit and delete operations done after turning on tracking
.commit({ type, rows });

// copy selected cells / rows within the grid or from one grid to another
.copy();

// generate a table having structure similar to and synchronized with the columns in the grid
.createTable({ $cont, data });

// store or access arbitrary data
.data({ rowData, rowIndx, dataIndx, data });

// delete a row from the local data at provided rowIndx
.deleteRow({ rowIndx, rowList, track, source, history, refresh });

// destroy the intance
.destroy();

// enable/disable
.disable();
.enable();

// put a cell in edit mode if the cell lies within the viewport
.editCell({ rowIndx, rowIndxPage, dataIndx, colIndx });

// put the first editable cell in the row in edit mode
.editFirstCellInRow({ rowIndx });

// export data
.exportData({ cssRules, filename, format, noheader, nopqdata, nopretty, render, sheetName, title, url, zip });

// filter data
// oper = 'replace' or 'add'
.filter({ oper, data:[ { dataIndx, condition, value, value2 } ] });

// apply flex whereby the columns adjust their widths so that all content is visible in the cells without text wrap
.flex({ dataIndx: [dataIndx], colIndx: [colIndx] });

// set focus upon a single cell
.focus({ rowIndxPage, colIndx });

Dynamic Grids Plugin with jQuery, ParamQuery Grid Plugin/Github, jquery grid responsive, paramquery grid tutorial


See Demo And Download

Official Website(paramquery): Click Here

This superior jQuery/javascript plugin is developed by paramquery. For extra Advanced usage, please go to the official website.

Related Posts

VenoBox-Responsive-jQuery-Lightbox-Plugin

Responsive Image Gallery Lightbox jQuery Plugin | VenoBox

VenoBox is a responsive jQuery modal window plugin suitable for images, embedded content, iFrames, Google Maps, Vimeo, and YouTube videos. The big difference compared to many other…

bootstrap-dropdown-on-hover

[Animation] Bootstrap Multi-Level Responsive Dropdown Menu

Bootstrap-based multi-level dropdown navigation menu with cool animations. The dropdown on Hover is a jQuery plugin used to create Bootstrap multi-level scroll-triggered dropdown menus with CSS3 animations…

Google-Translate-Dropdown-Customize-With-Country-Flag

Google Translate Dropdown Customize With Country Flag | GT API

Flag google translates jQuery text that takes advantage of the Google Cloud Translation API to translate web content between languages by selecting a country from the dropdown…

Bootstrap-Fileinput

HTML 5 File Input Optimized for Bootstrap 4.x./3.x with File Preview | Bootstrap Fileinput

bootstrap-fileinput is an improved HTML 5 file input  Bootstrap 5.x, 4.x and 3.x with file preview for different files, provides multiple selections, resumable section uploads, and more….

HStack-and-VStack-in-CSS

CSS Layout Components Horizontal/Vertical Stack | HStack and VStack

HStack and VStack in CSS – CSS layout components that (basically) stack anything horizontally and vertically. A pure CSS library that makes it easy to stack elements…

Floating-Whatsapp-Chat-Button

How to Add Floating Whatsapp Chat Button In HTML | venom-button

Venom Button is a very simple plugin for the jQuery floating WhatsApp button. Adds a floating button to your site that calls WhatsApp Click to Chat API. It will automatically start the WhatsApp…

Leave a Reply

Your email address will not be published. Required fields are marked *