ForgeComponents
en

Components

j-ServerGrid

jComponent 20 · jcomponent@20 component Example loaded with jComponent 20

BETA VERSION. This grid is designed for single page and enterprise applications. It's a simple alternative to the much more powerful j-DataGrid.

Data-source needs to contain:

{
	columns: [
		{
			id: 'name',
			name: 'Name',
			width: 150, // optional (default: config.colwidth)
			filtering: false, // optional (default: false)
			sorting: false, // optional (default: false)
			align: 1, // optional: 0 or left (default), 1 or center, 2 or right
			alignheader: 1, // optional: 0 or left (default), 1 or center, 2 or right
			alignfilter: 1, // optional: 0 or left (default), 1 or center, 2 or right
			icon: 'ti ti-home', // optional: column icon
			color: '#000000' // optional: color for all rows,
			dirsource: [{ id: 'String|Number|Boolean', name: '...' }] // optional: a dropdown filter (it needs "directory" component)
		}
	],
    items: [{ name: 'Row <b>1</b> will be bold', $class: 'NEW: css class for the row', $style: 'NEW: css for the row' }, { name: 'Row 2' }, ...] // items
    page: 1,    // current pages
    pages: 30,  // count of pages
    limit: 5,   // items limit per page
    count: 150  // count of items in DB
}

Configuration:

  • colwidth {Number} a default column width in pixels (default: 150)
  • pluralizepages {String} pluralization for pages (optional, default: # pages,# page,# pages,# pages)
  • pluralizeitems {String} pluralization for items (optional, default: # items,# item,# items,# items)
  • margin {Number} a top margin for height (optional, default: 0)
  • noborder {Boolean} can remove a border (default: false)
  • parent {String} selector for auto height option (default: window)
  • height {Number} a fixed height
  • filter {String} a default placeholder for all filters (optional)
  • click {String} a link to a path or function(row, row_element)
  • cell {String} a link to a path or function(row, cell_element, column)
  • exec {String} a link to function(type, filter, sort, page) for server-side operations (supported types: filter, page and sort)
  • opacity {Number} a default background opacity for column colors (default: 0.3);
  • NEW: scrollbarshadow {Boolean} enables scrollbar shadow (default: false)
  • NEW: scrolltop {Boolean} it automatically scrolls to the top after the data source is changed (default: true)

Good to know:

  • NULL('link.to.data') evaluates config.exec

Use it with <ui-component name="servergrid">. When the component is not loaded yet, jComponent downloads it on first use from the address in DEF.fallback (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

example.html
<ui-component name="servergrid" path="data" config="checkbox:1;height:500;exec:filtering"></ui-component>

<script id="datasource" type="text/json">
{
	"items": [
		{
			"id": "IuX45p1cl61f",
			"name": "Hello world!",
			"createdby": "Peter Sirka",
			"dtcreated": "2024-11-25T22:43:53.455Z"
		}
	],
	"count": 1,
	"page": 2,
	"limit": 50,
	"pages": 3,
	"columns": [
		{
			"id": "name",
			"name": "Message",
			"width": 300,
			"color": "#F4E8E8",
			"icon": "ti ti-envelope",
			"filtering": true,
			"sorting": true
		},
		{
			"id": "createdby",
			"name": "Created by",
			"filtering": true,
			"sorting": true
		},
		{
			"id": "dtcreated",
			"name": "Created",
			"icon": "ti ti-calendar",
			"filtering": true,
			"sorting": true
		}
	]
}
</script>


<script>

	var data = PARSE('#datasource');

	function filtering(type, filter, sort, page) {
		console.log('Type:', type, 'Filter:', filter, 'Sort:', sort, 'Page:', page);
		UPD('data');
	}

</script>