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 with Multiple Selection

Grid supports multiple selection. Single select is the default. For additional rows use Ctrl key or checkboxes.

To select all rows click the checkbox in the header.

Example also showcases use of onTrackMappedRecords in combination with onCreateFilter callback. Using onTrackMappedRecords we can access filtered records.

NamePhoneCity
Troy Vandervort681-141-2569Bobbiefurt
Irma Flatley194-695-6329Ashtonview
Titus Hane466-908-6410West Catalina
Gonzalo Krajcik550-439-5054Alexandriamouth
Mylene Kulas534-556-3075Roobport
Mossie Cartwright153-492-8342Port Kolby
Kiarra Wilderman384-782-2415East Alysa
Dillon Weber427-975-3055Hartmannchester
Zelma Gerhold145-293-9998East Lilianehaven
Floy Labadie731-903-8866New Effie
Kareem Kub725-709-2117Tonybury
Clovis Paucek790-766-7745Willytown
Santiago Senger614-661-9513Port Ardithfort
Dalton Murray962-781-8835Wellingtonview
Meta Schultz864-762-2331Lake Lucile
Era Bartoletti589-132-6809Lake Lamarland
Collin Auer230-146-0011Maybellefort
Marcelo Bergstrom359-753-1136Hodkiewiczborough
Joesph Bruen282-114-5222Hammesstad
Pinkie Bins546-670-1111Lake Ottis
ControllerIndex
<Grid
    records-bind='$page.records'
    tyle={{width: "100%"}}
    columns={[{
        header: {items: <cx><Checkbox value-bind="$page.selectAll" indeterminate unfocusable/></cx>},
        field: 'selected',
        style: 'width: 1px',
        items: <cx><Checkbox value-bind="$record.selected" unfocusable/></cx>
    },
        {header: 'Name', field: 'fullName', sortable: true},
        {header: 'Phone', field: 'phone'},
        {header: 'City', field: 'city', sortable: true}
    ]}
    selection={{type: PropertySelection, bind: "$page.selection", multiple: true}}
    sorters-bind="$page.sorters"
    filterParams-bind='$page.searchText'
    onCreateFilter={(searchText) => {
        if (!searchText) return () => true;
        let predicate = getSearchQueryPredicate(searchText);
        return record => predicate(record.fullName) || predicate(record.phone) || predicate(record.city);
    }}
    onTrackMappedRecords='updateSelection'
/>
Copied!Cx Fiddle