Our blazing fast Grid component built with pure JavaScript


Post by prashantgoel »

In this example:

https://bryntum.com/products/grid/examples/contextmenu/

When a menu item is clicked (example "Copy"), how do I get the row for which the menu item has been clicked? I need to be able to read the value from a field in that row to perform some action.


Post by marcio »

Hey prashantgoel,

Thanks for reaching out!

You can use the following approach (you can test on the demo that you mentioned)

features : {
        cellMenu     : {
		items : {
			copy: {
 				onItem: ({record}) => {
					console.log(record)
				}
			}
		}
	}
}

Best regards,
Márcio


Post by prashantgoel »

We were given this code earlier to add a widget as a custom column at the end. Should this also work, or am I doing something wrong? The "record" is returned as undefined in the console.

                
widgets: [{ type: 'button', icon: 'b-fa b-fa-fw b-fa-ellipsis-v', menu: { type: 'menu', anchor: true, autoShow: false, items: [ { icon: 'fa fa-fw fa-file-signature', text: 'View Responses' }, { icon: 'fa fa-fw fa-times-circle', text: 'Clear Consent', field: 'personID' }, { icon: 'fa fa-fw fa-file-signature', text: 'Survey List (Read-Only)' }
], // Method is called for all ancestor levels onItem: ({ item, record, column }) => { console.log('item is', record ); } }]

Post by tasnim »

Hi,

Please check this thread to get the code viewtopic.php?p=138820#p138820
You'd need to use https://www.bryntum.com/products/grid/docs/api/Grid/view/GridBase#function-getRecordFromElement to get the record from the element

Hope I understood your requirement 😊


Post by Animal »

Here's how to do it: https://codepen.io/Animal-Nige/pen/KKEQxGa?editors=0010

We will make the cellInfo contextual information block public. The example in the API docs uses it, so it should be documented: https://www.bryntum.com/products/grid/docs/api/Grid/column/WidgetColumn

Also, we will illustrate usage of object as items which is best practice, so that there is always a ref which can identify a widget.


Post Reply