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
Coty PfefferEuropeSafariUbuntu68
Percival KrisEuropeFirefoxAndroid35
Jeremie MitchellSouth AmericaInternet ExplorerAndroid74
Bailey ToyAfricaInternet ExploreriOS50
Pedro ConnAntarcticaEdgeMac OS12
Ahmad LockmanAntarcticaOperaMac OS92
Sydni SchowalterAfricaInternet ExplorerUbuntu32
Johnnie BayerAustraliaChromeWindows76
Dominic TorpAustraliaChromeWindows78
Dagmar HauckAsiaSafariAndroid22
Johnny BorerSouth AmericaInternet ExplorerAndroid44
Oscar KlingSouth AmericaEdgeMac OS36
Lonzo CarrollAfricaChromeUbuntu70
Quinn LeannonEuropeEdgeWindows38
Kaylah BayerAntarcticaOperaMac OS23
Chelsea SawaynNorth AmericaOperaAndroid62
Brendon NitzscheNorth AmericaOperaAndroid50
Katrina CreminAntarcticaOperaUbuntu19
Verner GleichnerAustraliaOperaUbuntu71
Tyshawn HermanNorth AmericaOperaUbuntu66
Alexys TreutelAntarcticaFirefoxMac OS53
Trisha OlsonAsiaSafariUbuntu19
Helen WeissnatAfricaOperaUbuntu22
Prudence StrackeNorth AmericaOperaiOS96
Damaris BuckridgeAsiaEdgeiOS96
Kellen DavisEuropeInternet ExplorerAndroid52
Amira FeeneyAsiaChromeAndroid44
Mustafa JonesSouth AmericaInternet ExplorerAndroid22
Maxine ShieldsAfricaEdgeUbuntu80
Kaitlyn WizaAustraliaSafariMac OS25
Everett LittleNorth AmericaSafariUbuntu95
Stewart WillmsAsiaSafariMac OS27
Mireille MoenAsiaInternet ExplorerUbuntu55
Dora PagacAsiaOperaMac OS87
Itzel GleichnerAustraliaOperaMac OS25
Victoria KonopelskiAfricaInternet ExploreriOS11
Carli LittleAfricaSafariAndroid52
Carrie AbbottEuropeInternet ExplorerAndroid66
Gerard MohrNorth AmericaFirefoxUbuntu13
Jayden BeierSouth AmericaOperaMac OS71
Isom JerdeEuropeInternet ExploreriOS8
Dedrick HilpertNorth AmericaInternet ExploreriOS2
Bret GradyNorth AmericaFirefoxWindows65
Elsie OrtizAfricaSafariUbuntu94
Zackary MayerAsiaEdgeAndroid54
Vaughn HintzEuropeOperaAndroid46
Forrest PfefferEuropeFirefoxiOS15
Maybelle SchillerNorth AmericaInternet ExplorerMac OS1
Naomi QuigleyAsiaChromeAndroid23
Britney KuhlmanAfricaEdgeWindows20
Antoinette WardAsiaFirefoxWindows48
Roger RunolfssonAustraliaChromeMac OS21
Linda BauchEuropeSafariUbuntu23
Rosalyn EmardEuropeOperaUbuntu27
Pearline KonopelskiAsiaEdgeMac OS89
Tiffany MetzAntarcticaInternet ExplorerMac OS10
Columbus SchinnerAntarcticaEdgeAndroid98
Mckenna DoyleAustraliaOperaiOS69
Jalyn KeeblerAsiaOperaAndroid62
Freddie JonesAfricaOperaAndroid84
Tobin MaggioEuropeOperaWindows66
Caleb HesselEuropeFirefoxUbuntu21
Brisa SchambergerNorth AmericaFirefoxUbuntu31
Vicente GusikowskiAfricaSafariWindows40
Donald MedhurstSouth AmericaInternet ExplorerUbuntu28
Cordia BoyleAsiaSafariWindows27
Mina WatsicaNorth AmericaInternet ExplorerUbuntu65
Christelle GerlachAsiaOperaiOS66
Braulio WunschAsiaChromeAndroid75
Clement VandervortAntarcticaChromeWindows59
Avis HuelNorth AmericaInternet ExplorerMac OS20
Haylie HoegerAsiaFirefoxAndroid42
Horace ZiemeAustraliaSafariMac OS83
Leonard RitchieAfricaSafariUbuntu45
Tyrese LangworthAntarcticaInternet ExplorerAndroid51
Lyric MarksAfricaChromeMac OS48
Reynold BernierNorth AmericaOperaAndroid95
Sheridan McKenzieAsiaOperaiOS81
Tia McClureAustraliaChromeWindows72
Remington KuhlmanAustraliaInternet ExploreriOS22
Devin StreichEuropeSafariAndroid43
Sigrid CroninNorth AmericaChromeMac OS11
Diana LebsackAsiaChromeiOS97
Jayda GreenAsiaInternet ExplorerUbuntu50
Florence TorphyAfricaFirefoxMac OS24
Herminia ProhaskaAfricaInternet ExplorerMac OS16
Rocio CroninAntarcticaOperaAndroid99
Jackson GusikowskiSouth AmericaEdgeMac OS42
Callie ConroyAsiaChromeUbuntu94
Lon MullerAustraliaOperaUbuntu49
Okey WintheiserEuropeInternet ExploreriOS90
Toney NikolausAustraliaEdgeAndroid41
Alaina MurraySouth AmericaOperaWindows95
Eulah QuigleyAfricaSafariUbuntu86
Markus GerlachNorth AmericaOperaMac OS15
Margarete CristAsiaInternet ExplorerAndroid25
Burley CartwrightEuropeInternet ExploreriOS62
Jodie KubNorth AmericaSafariWindows65
Louie HarrisEuropeInternet ExplorerMac OS98
Kiara KunzeAustraliaFirefoxAndroid18
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