@@ -35,11 +35,6 @@ const grid = new Grid({
3535 plugin: {
3636 // install the RowSelection plugin
3737 component: RowSelection,
38- // RowSelection config
39- props: {
40- // use the "email" column as the row identifier
41- id: (row) => row.cell(2).data
42- }
4338 }
4439 },
4540 {
@@ -79,10 +74,7 @@ const grid = new Grid({
7974 // select all rows by default!
8075 data: () => true,
8176 plugin: {
82- component: RowSelection,
83- props: {
84- id: (row) => row.cell(2).data
85- }
77+ component: RowSelection
8678 }
8779 },
8880 {
@@ -107,85 +99,6 @@ grid.on('ready', () => {
10799`
108100} scope={{RowSelection}} />
109101
110- ## Row selection extension
111-
112- Grid.js enables you to write custom plugins and extend the core functionality. In this example, we are developing a custom
113- plugin which listens to the Selection plugin events and populates a list of selected rows.
114-
115-
116- <LiveExample children={
117- `
118- class SelectionsList extends BaseComponent {
119- constructor(props, context) {
120- super(props, context);
121-
122- this.state = {
123- selectedRows: [ ]
124- };
125- }
126-
127- componentDidMount() {
128- const grid = this.config.instance;
129-
130- grid.on('ready', () => {
131- // find the plugin with the give plugin ID
132- const checkboxPlugin = this.config.plugin.get('selectRow');
133-
134- // subscribe to the store events
135- checkboxPlugin.props.store.on('updated', (state) => {
136- this.setState({
137- selectedRows: state.rowIds
138- });
139- });
140- });
141- }
142-
143- render() {
144- if (!this.state.selectedRows.length) {
145- return h('b', {}, 'Select some rows...');
146- }
147-
148- return h(
149- 'ul',
150- {},
151- this.state.selectedRows.map((rowId) => h('li', {}, rowId))
152- );
153- }
154- }
155-
156- const grid = new Grid({
157- columns: [
158- {
159- id: 'selectRow',
160- name: 'Select',
161- plugin: {
162- component: RowSelection,
163- props: {
164- id: (row) => row.cell(2).data
165- }
166- }
167- },
168- {
169- name: 'Name',
170- formatter: (cell) => \` Name: \$ {cell}\`
171- },
172- 'Email',
173- ] ,
174- sort: true,
175- data: Array(5).fill().map(x => [
176- faker.name.findName(),
177- faker.internet.email(),
178- ] )
179- });
180-
181- grid.plugin.add({
182- id: 'selectionsList',
183- component: SelectionsList,
184- position: PluginPosition.Footer,
185- });
186- `
187- } scope={{RowSelection}} />
188-
189102::: tip
190103Follow the [ Advanced Plugin] ( ../advanced-plugins.md ) article to learn more about writing Grid.js plugins!
191104:::
0 commit comments