grafana / scenes

Build Grafana dashboards directly in your Grafana app plugins.
https://grafana.com/developers/scenes
Apache License 2.0
139 stars 21 forks source link

DataLinks: Missing frame in onClick handler callback #355

Open ptrkkr opened 1 year ago

ptrkkr commented 1 year ago

Hi!

I want to show panels in the secondary view of my SplitLayout, based on multiple fields in the table of my primary view.

I got something like that:

 b.matchFieldsWithName('someCol')
                .overrideLinks([
                    {
                        title: '${__data.fields[0].text}',
                        url: '',
                        onClick: (e: DataLinkClickEvent) => {
                            const field1 = e.origin.field.values.get(e.origin.rowIndex)
                            // const field2 = e.origin.fields[1].values.get(e.origin.rowIndex)
                            // const field3 = e.origin.fields[2].values.get(e.origin.rowIndex)
                            console.log(e)
                            splitter.setState({
                                secondary: new SceneFlexItem({
                                    minWidth: 500,
                                    body: buildSomePanel(field1) 
                                    // body: buildSomePanel(field1, field2, field3) // this is what i actually want to do 
                                }),
                            });
                        },
                    },
                ])

${__data.fields[0].text} or ${__data.fields[1].text} or ${__data.fields[5].text} is working perfectly fine in .overrideLinks() when i use it in title: or url: but I need this information also in the onClick:. Is there any way to access all fields of one row (or even the whole table) in onClick:? Or is there any other way to achieve this? e.origin seems not to contain the information I need.

Thx!

torkelo commented 1 year ago

@ptrkkr I think we are missing the frame on the click event: https://github.com/grafana/grafana/blob/main/packages/grafana-ui/src/utils/table.ts#L28

if we are to add it I think we need to update a few visualizations. @dprokop what do you think? seems like a good thing to add to the context

dprokop commented 1 year ago

I do agree. Think we need to update the interface of the DataLinkClickEvent to be actually typed. Right now we do not pass any specific type there so origin is always any.

ptrkkr commented 9 months ago

Is there an update when we can expect this one?

ptrkkr commented 4 months ago

Still nothing new on this one? :sweat: