K-table Options Dropdown: How to get row/index for option

Hi there,
im currently struggling with the k-table component. I am using an area dropdowns definition as follows:

'watched-files' => [
  'label'   => 'Dateiaufrufe',
  'menu'    => false,
  'dialogs' => [...],
  'dropdowns' => [
     require __DIR__ . '/watched-files/dropdowns/options.php'
  ]
]

options.php

return [
    'pattern' => 'watched-files/(:any)',
    'action'  => function ( $id ) {
       // How to get the $id from the table row in which option was clicked
    }
];

The vue-File with the k-table looks like this:

<k-table 
      :columns="{
          name: { label: 'Dateiname', type: 'text' },
          watched: { label: 'Angesehen', type: 'html', width: '1/6'}
      }"
      :rows="files"
      :options="$dropdown('watched-files/'<ROW-INDEX-INFORMATION>)"
/>

Everything is fine. The Options Dropdown shows my options defined in the options.php file.

Question is: How can I get the rowIndex or id or whatever to identify which row option I have clicked, in order to do sth. with the row.

Of course I could build it with an v-for with my own table, but I want to know how to get this done with the k-table component.

Hi @PatrickFox

you may listen to the option event like so:

<k-table 
      :columns="{
          name: { label: 'Dateiname', type: 'text' },
          watched: { label: 'Angesehen', type: 'html', width: '1/6'}
      }"
      :rows="files"
      :options="$dropdown('watched-files/'<ROW-INDEX-INFORMATION>)"
     @option="doSomething"
/>

You get the native event, the row and the row index as arguments.

It is emited here in the table component

Edit: I edited this because I misunderstood you the first time :wink:

Hey @benzin,

I tried what you suggested and wanted to log the arguments to the console without any luck:

methods: {
 doSomething(option, row, rowIndex) {
   console.log(option);
 },
}

Either im missing sth. or the arguments are attached to sth else?

Question is, how do I get these arguments passed to the options.php, if this is possible? Otherwise I have to put the logic inside the above method.

Thanks for your help in advance :slight_smile: