Griddle icon indicating copy to clipboard operation
Griddle copied to clipboard

How to get selected items from grid using checkbox

Open nalumachurakesh opened this issue 8 years ago • 5 comments

Hi,

I'm using isMultipleSelection and uniqueIdentifier properties to select items. But, I couldn't find how to get those selected items.

Could you please provide me how to get selected items ids from grid using checkbox.

Thanks, Rakesh

nalumachurakesh avatar Oct 12 '16 12:10 nalumachurakesh

Hi,

Can't seem to find any documentation on isMultipleSelection and uniqueIdentifier properties. Can you point me in direction of where these properties are documented?

mlubovac avatar Nov 08 '16 21:11 mlubovac

@mlubovac I too couldn't find any documentation on isMultipleSelection and uniqueIdentifier properties. But, I have implemented functionality using those properties and it worked as per my needs.

nalumachurakesh avatar Nov 09 '16 00:11 nalumachurakesh

Can you provide an example of how to use such properties?

mlubovac avatar Nov 09 '16 04:11 mlubovac

Following is the code to create grid with isMultipleSelection and uniqueIdentifier properties

<GriddleDataGrid ref='griddleGrid' showFilter={true} results={datasource} resultsPerPage={5} columnMetadata={this.columnMetadataDialog} columns={this.columnIdentitiesDialog} useGriddleStyles={false} tableClassName='table table-striped' useCustomPagerComponent={false} infiniteScrollLoadTreshold={5} useFixedHeader={true} isMultipleSelection={true} uniqueIdentifier='someUniqueValue' bodyHeight={300} />;

Here 'someUniqueValue' is a unique value property in your data source.

Using ref of react you can access the selected values in the grid. Syntax would be, this.refs.griddleGrid.getSelectedRowIds().

nalumachurakesh avatar Nov 09 '16 15:11 nalumachurakesh

Also, you can store selectedRowIds in your own state and pass them into the selectedRowIds prop. onSelectionChange prop can be used to pass a function to be run when selectedRowIds change. Set state inside that function.

tim-phillips avatar Nov 11 '16 00:11 tim-phillips