vue3-easy-data-table icon indicating copy to clipboard operation
vue3-easy-data-table copied to clipboard

Can expand-row event emit item instead of index?

Open mokadevcloud opened this issue 2 years ago • 6 comments

Hi, I am trying to use expand-row with sorting on various colums as per user's choice. At the moment, the callback function triggered on expand-row receives the index of the row. But that doesn't tell us which item has been expanded, unless we are sure of the current sorted order. I feel it would be easier to have the item directly, as in the case of click-row. Do you think this is feasible? Thanks

mokadevcloud avatar Dec 05 '22 17:12 mokadevcloud

I am afraid that it will be confusing when there are duplicated items.

HC200ok avatar Dec 07 '22 09:12 HC200ok

I see. With the current implementation, we would have to keep track of the sortBy field and the sortMethod, and internally ourselves sort the items by this field and method, to know which item the returned index corresponds to. Is this what you would recommend? Thanks

mokadevcloud avatar Dec 07 '22 09:12 mokadevcloud

Yes,but I will provide item with index for your case.

HC200ok avatar Dec 07 '22 10:12 HC200ok

Great, thank you!

mokadevcloud avatar Dec 07 '22 10:12 mokadevcloud

@mokadevcloud Please update to the latest version 1.5.20 then you can use the second param of expand-row event like this:

<template>
  <DataTable
    :headers="headers"
    :items="items"
    @expand-row="load"
  />
</template>
<script>
const load = async (index: number, item: Item): Promise<void> => {
  console.log(index);
  console.log(item);
};
</script>

HC200ok avatar Dec 07 '22 12:12 HC200ok

Unfortunately the second param item is allways undefinded. Version: 1.5.45

stefanschlipfi avatar Jun 22 '23 11:06 stefanschlipfi