VolkovLabs / volkovlabs-dynamictext-panel

Business Text Panel for @grafana
https://docs.volkovlabs.io
Apache License 2.0
78 stars 14 forks source link

question: column sort but use a different value #195

Closed yosiasz closed 12 months ago

yosiasz commented 12 months ago

Greetings,

Can one enable column sorting on this super awesome plugin? So what I am thinking is give the following data

Name, Value, Metric
Server1, 10000, 10000 Lira
Server3, 54.3, 54.3 Rubble

The panel would only display, Name and Metric column. But clicking on that column sorts it on the Value data point.

I think typing this out has given me an idea. Via a js function one could reorder the data. 🦆

Thanks!

mikhail-vl commented 12 months ago

@yosiasz, Yes, JavaScript function will work.

We plan to add support for external CSS and JavaScript scripts, which will allow to include data tables modules, which display sortable tables. Will it work for your use case?

mikhail-vl commented 12 months ago

Reference: https://github.com/VolkovLabs/volkovlabs-dynamictext-panel/issues/173

yosiasz commented 12 months ago

wow!!! I was just about to ask about external CSS and JavaScript scripts. Always one step ahead of the game champ! @mikhail-vl

yosiasz commented 12 months ago

for now I am just going with this

SortData = () => {
  console.log('Pre sort', data.data)
  data.data.sort((a, b) => a.UsedNumeric - b.UsedNumeric);
  console.log('After sort', data.data)
  return data;
};

probably should use ... spread

mikhail-vl commented 12 months ago

@yosiasz Should be ready end of the week to test.