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

**URL:** https://forum.getkirby.com/t/k-table-options-dropdown-how-to-get-row-index-for-option/28541
**Category:** Questions
**Tags:** v3
**Created:** [May 9, 2023, 6:50pm UTC](https://forum.getkirby.com/t/k-table-options-dropdown-how-to-get-row-index-for-option/28541 "2023-05-09T18:50:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![PatrickFox](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/patrickfox/32/11826_2.png) [@PatrickFox](https://forum.getkirby.com/u/PatrickFox)
#### Post date: [May 9, 2023, 6:50pm UTC](https://forum.getkirby.com/t/k-table-options-dropdown-how-to-get-row-index-for-option/28541/1 "2023-05-09T18:50:51Z")

</div>

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

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

```

options.php

```auto
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:

```auto
<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.

---

<div class="post-metadata">

### Author: ![benzin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/benzin/32/6193_2.png) [@benzin](https://forum.getkirby.com/u/benzin)
#### Post date: [May 10, 2023, 8:48am UTC](https://forum.getkirby.com/t/k-table-options-dropdown-how-to-get-row-index-for-option/28541/2 "2023-05-10T08:48:27Z")

</div>

Hi @PatrickFox

you may listen to the `option` event like so:

```auto
<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](https://github.com/getkirby/kirby/blob/282b1e25faa0bc24c903237a7484dc45fa475c36/panel/src/components/Layout/Table.vue#L307-L309)

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

---

<div class="post-metadata">

### Author: ![PatrickFox](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/patrickfox/32/11826_2.png) [@PatrickFox](https://forum.getkirby.com/u/PatrickFox)
#### Post date: [May 11, 2023, 6:24am UTC](https://forum.getkirby.com/t/k-table-options-dropdown-how-to-get-row-index-for-option/28541/3 "2023-05-11T06:24:38Z")

</div>

Hey @benzin,

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

```auto
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 🙂
