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
Erica Moore364-558-3009Port Sigmund
Etha Johnston612-948-4655Jovanychester
Gregorio Schultz242-566-3995Lake Zane
Daphne Olson085-044-7211Paolohaven
Kiel Schoen621-498-8385Billychester
Lavonne Murazik617-778-2677Volkmanville
Syble Boehm237-975-0443Mertzhaven
Adriel Pfannerstill133-144-1817Romaguerahaven
Skyla Kshlerin799-550-1954Lake Travon
Seth Runte156-156-1238Lake Alishaville
Daphne Ward361-987-8735Keshawnport
Allison Gleason574-355-5752Charlotteshire
Barbara Brekke900-196-8427Trystanport
Amber Auer255-169-9901West Allen
Rocky Kuhlman397-869-9811North Jamil
Alexzander Goldner615-543-7935East Zachary
Magnolia Johnston319-533-8939East Wendellfurt
Alyce Trantow627-763-5808Emiliabury
Rollin Nikolaus995-227-3656Lake Abagail
Mabel Ledner668-203-4977Blaiseborough
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