vue3-easy-data-table
vue3-easy-data-table copied to clipboard
Can expand-row event emit item instead of index?
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
I am afraid that it will be confusing when there are duplicated items.
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
Yes,but I will provide item with index for your case.
Great, thank you!
@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>
Unfortunately the second param item is allways undefinded. Version: 1.5.45