You're viewing the legacy site. Visit cxjs.io/docs for the latest documentation. Legacy site. Visit cxjs.io/docs for new docs.

Documentation

Report Edit

Grid

import {Grid} from 'cx/widgets';

Grid is a versatile component used to display tabular data. Grid control in Cx has many features such as fixed headers, single and multiple selection modes, sorting, filtering, grouping and aggregation, rich cell content (including headers), tree columns, etc.

Name
Continent
Browser
OS
Visits
Karl BoscoSouth AmericaInternet ExplorerMac OS6
Alexandro MayerAfricaFirefoxUbuntu51
Darren NicolasAfricaFirefoxMac OS9
Marlen SchmidtEuropeOperaAndroid93
Leone McLaughlinNorth AmericaOperaMac OS4
Chadd RolfsonNorth AmericaEdgeWindows19
Abelardo AuerSouth AmericaOperaMac OS7
Kristoffer CarterAustraliaEdgeMac OS9
Valentin FayAntarcticaOperaUbuntu10
Adrianna KutchAustraliaOperaAndroid69
Harmon BergstromAsiaFirefoxWindows88
Zaria CummerataSouth AmericaOperaMac OS3
Rigoberto SteuberAsiaInternet ExplorerMac OS88
Hayley WintheiserAfricaEdgeAndroid37
Misty SchmittAustraliaInternet ExplorerAndroid63
Haleigh FriesenNorth AmericaInternet ExplorerAndroid34
Shayne VonAntarcticaChromeMac OS33
Gordon HowellNorth AmericaInternet ExplorerMac OS11
Nicole McCulloughAustraliaInternet ExplorerWindows63
Monserrat LabadieAfricaSafariUbuntu85
Geovanny KlockoAsiaFirefoxAndroid35
Alfreda TorphyAustraliaSafariAndroid88
Brendan DooleyNorth AmericaFirefoxAndroid42
Andreanne CroninEuropeOperaUbuntu64
Maia MannAustraliaSafariAndroid51
Mandy LegrosAfricaEdgeUbuntu70
Damaris DooleyAsiaSafariAndroid6
Tod PourosAsiaOperaUbuntu94
Marcos KubAsiaFirefoxMac OS8
Adonis DachAsiaSafariAndroid84
Ursula HeidenreichNorth AmericaInternet ExplorerUbuntu26
Randy JerdeSouth AmericaSafariMac OS35
Elvis GradySouth AmericaOperaAndroid27
Cruz StiedemannAsiaSafariWindows84
Tristin SawaynAustraliaChromeAndroid64
Monserrat TorpNorth AmericaOperaUbuntu1
Lillian DareNorth AmericaEdgeMac OS75
Celestino SchuppeAsiaSafariMac OS35
Ines LubowitzAfricaInternet ExplorerWindows44
Rashad LangworthSouth AmericaFirefoxMac OS58
Lowell GloverAfricaFirefoxWindows85
Dillan PredovicAfricaInternet ExplorerAndroid31
Gordon DooleyNorth AmericaSafariUbuntu43
Madilyn ThompsonSouth AmericaSafariAndroid12
Maximillian AdamsSouth AmericaSafariWindows52
Wendy DurganAfricaOperaiOS83
Judd ShanahanAustraliaSafariAndroid60
Jerad DachAfricaFirefoxMac OS72
Zackery BeckerAustraliaFirefoxAndroid91
Roberto ChamplinEuropeEdgeMac OS93
Charles WymanAsiaEdgeiOS48
Beverly BaileyAustraliaChromeUbuntu70
Susie HillsSouth AmericaInternet ExplorerMac OS6
Addison BorerAntarcticaSafariMac OS11
Eino FunkAsiaSafariUbuntu48
Emery SwiftAustraliaSafariAndroid37
Ian GreenholtAntarcticaOperaUbuntu76
Mohamed BradtkeAfricaInternet ExploreriOS53
Shyanne KleinNorth AmericaOperaUbuntu13
Adelbert BeattyAustraliaSafariWindows7
Wilfredo KrisAsiaEdgeMac OS39
Anibal MillerAfricaSafariMac OS24
Kris HayesAfricaFirefoxMac OS27
Tianna BuckridgeSouth AmericaFirefoxMac OS20
Cathrine BaumbachSouth AmericaInternet ExplorerUbuntu3
Camren HarveyEuropeInternet ExplorerMac OS72
Cameron DareEuropeFirefoxUbuntu16
Toy ThompsonAfricaInternet ExplorerWindows77
Chesley StoltenbergSouth AmericaFirefoxMac OS66
Gardner BalistreriAsiaEdgeUbuntu16
Katherine GloverAsiaEdgeMac OS96
Audreanne VonNorth AmericaChromeUbuntu13
Clotilde LindgrenAntarcticaOperaMac OS6
Furman KundeEuropeOperaAndroid16
Monica CruickshankSouth AmericaOperaMac OS81
Dan KleinEuropeSafariMac OS5
Jordon GoyetteAsiaOperaMac OS88
Michelle GaylordNorth AmericaEdgeUbuntu52
Rickie BrownSouth AmericaFirefoxUbuntu82
Christina TerryAsiaChromeWindows5
Yolanda LockmanAustraliaFirefoxMac OS63
Eugenia LueilwitzAfricaOperaiOS76
Felipa ReichertSouth AmericaInternet ExplorerUbuntu36
Wendy GerlachAustraliaSafariUbuntu46
Tyra MillerAustraliaOperaUbuntu72
Brayan WaelchiAustraliaInternet ExplorerUbuntu42
Jordan MarquardtNorth AmericaOperaAndroid91
Jeff DanielSouth AmericaOperaMac OS22
Muhammad LynchAsiaFirefoxMac OS29
Luisa WymanSouth AmericaSafariUbuntu46
Grover DareAustraliaEdgeUbuntu9
Hailee NolanAustraliaFirefoxAndroid15
Neal MertzAsiaFirefoxAndroid49
Alan LangworthAustraliaInternet ExplorerWindows91
Joel EmardAsiaOperaWindows38
Margot WuckertNorth AmericaOperaUbuntu66
Haley KlockoSouth AmericaFirefoxiOS21
Moses ConroyAntarcticaInternet ExplorerUbuntu99
Cristal MaggioAsiaChromeUbuntu31
Shea HoweNorth AmericaSafariMac OS54
Name
Continent
Browser
OS
Visits
<Grid records-bind='$page.records'
    style={{width: "100%"}}
    columns={[
        { header: 'Name', field: 'fullName', sortable: true },
        { header: 'Continent', field: 'continent', sortable: true },
        { header: 'Browser', field: 'browser', sortable: true },
        { header: 'OS', field: 'os', sortable: true },
        { header: 'Visits', field: 'visits', sortable: true, primarySortDirection: 'DESC' }
    ]}
    selection={{type: KeySelection, bind:'$page.selection'}}
/>
Copied!Cx Fiddle

GridColumnColumn HeaderGroupingDrag & Drop

PropertyDescriptionType
border

Set to true to add default border around the table. Automatically set if grid is scrollable.

boolean
buffered

Set to true to render only visible rows on the screen. This greatly improves performance for grids with a lot of data. Works only if the grid is scrollable.

boolean
cached

Set to true to enable row caching. This greatly improves grid performance on subsequent render operations, however, only changes on records are allowed. If grid rows display any data outside records, changes on that data will not be caught.

boolean
clearableSort

If set, clicking on the column header will loop between ASC, DESC and no sorting order, instead of ASC and DESC only.

boolean
columns

An array of columns. Check column configuration options in the section below.

array
grouping

An array of grouping level definitions. Check allowed grouping level properties in the section below.

array
headerMode

Determines header appearance. Supported values are plain and default. Default mode is used if some of the columns are sortable. Plain mode better suits reports and other scenarios in which users do not interact with the grid.

string
measureRowHeights

Used when rows have variable heights to improve buffered rendering by measuring and caching rendered row heights. Default value is false.

boolean
pageSize

Page size used to fetch records during infinite scrolling. Default value is 100.

number
records

An array of records to be displayed in the grid.

array
scrollable

Set to true to add a vertical scroll and a fixed header to the grid. Scrollable grids shoud have height or max-height set. Otherwise, the grid will grow to accomodate all rows.

boolean
selection

Selection configuration. See Selections for more details.

config
sortDirection

A binding used to store the sort direction. Available only if sorters are not used.

string
sortField

A binding used to store the name of the field used for sorting grids. Available only if sorters are not used.

string
sorters

A binding used to store the sorting order list. Commonly used for server-side sorting.

array
vlines

Set to true to add vertical gridlines.

boolean
allowsFileDrops

Set to true to allow the grid to receive drag and drop operations containing files.

boolean
bufferSize

Number of rendered rows in buffered grids. Default value is 60.

number
bufferStep

Number of rows to be scrolled before buffer adjustment. Default value is 15.

number
class
className

Additional CSS classes to be applied to the element. If an object is provided, all keys with a "truthy" value will be added to the CSS class list.

string/object
columnParams

Whenever columnParams change, columns are recalculated using the onGetColumns callback.

object
dataAdapter

Data adapter is used for converting data in a list of records. Used to enable grouping and tree operations. See TreeGrid for more details.

object
defaultSortDirection

Default sort direction.

string
defaultSortField

Default sort field. Used if neither sortField or sorters are set.

string
emptyText

Text to be displayed instead of an empty table.

string
filterParams

Parameters which will be passed to the onCreateFilter callback. Take a look at the example here.

object
fixedFooter

Set to true to add a fixed footer at the bottom of the grid.

boolean
focusable

Set to true or false to explicitly define if grid is allowed to receive focus.

boolean
groupingParams

Whenever groupingParams change, columns are recalculated using the onGetGrouping callback.

object
hoverChannel

A value used to identify the group of components participating in hover effect synchronization. See HoverSync.

string
lockColumnWidths

Set to true to lock column widths after the first render. This is helpful in pagination scenarios to maintain consistent looks across pages.

boolean
mod

Appearance modifier. For example, mod="big" will add the CSS class .cxm-big to the block element.

string/array
onCreateFilter

Callback function used to create a filter. The function accepts filterParams as an argument and it should return a predicate function used to filter the records. Take a look at the example here.

function
onCreateIsRecordDraggable

Callback function used to specify which row is draggable. It should return a predicate which accepts a record and returns a boolean indicating wheter that record is draggable or not.

function
onCreateIsRecordSelectable

Callback function used to specify which row is selectable and which not.

function
onGetColumns

Callback function used to dynamically calculate columns. The function accepts resolved columnParams as a first argument and it should return either columns (array of column configurations) or row (grid row configuration) for multi-line scenarios.

function
onGetGrouping

Callback function to retrieve grouping data. Accepts groupingParams as a first argument and should return a grid grouping configuration.

function
onRef

Callback function to get grid component and instance references on component init.

function
onRowClick

Callback function to be executed when a row is clicked.

function
onRowContextMenu

Callback function to be executed when a row is right-clicked.

function
onRowDoubleClick

Callback function to be executed when a row is double-clicked.

function
onRowKeyDown

Callback function to be executed on key down. Accepts instance of the currently focused record as the second argument.

function
onTrackMappedRecords

Callback function to track and retrieve displayed records. Accepts new records as a first argument. If onCreateFilter callback is defined, filtered records can be retrieved using this callback. See its usage in the example here.

function
outerLayout

Defines the outer layout which wraps the widget.

widget
preSorters

Additional sorters to be prepended to the actual list of sorters.

array
preserveGroupOrder

When enabled, groups are shown in the same order as the source records.

boolean
putInto
contentFor

Used with outer layouts. Specifies the name of the content placeholder which should render the widget.

string
remoteSort

Set to true if sorting is done remotely, on the server-side. Default value is false.

boolean
row

A parameter that allows defining multiple lines in a row. Attributes of the row object: line1 - defines the first line, line2 - defines the second line, style - style object applied to the wrapper div, class - additional CSS classes to be applied to the element. If an object is provided, all keys with a "truthy" value will be added to the CSS class list.

object
rowHoverId

A value used to uniquely identify the record within the hover sync group. See HoverSync.

string
scrollResetParams

Parameters whose change will cause the scroll to be reset.

object
scrollSelectionIntoView

Set to true to add ensure that selected record is automatically scrolled into the view on selection change.

boolean
sortOptions

Options for data sorting. See Intl.Collator options for more info.

record
style

Style object applied to the wrapper div. Used for setting the dimensions of the element.

string/object
vdomKey

Key that will be used as the key when rendering the React component.

string
visible
if

Visibility of the widget. Defaults to true.

boolean