get the row index in q-table
-
get the row index in q-table
my configuration is:<q-table dense :data="dataTable" :pagination.sync="pagination" @request="onRequest" binary-state-sort :columns="columns" row-key="CompanyID" selection="single" :selected.sync="selected" @selection="handlerSelection" separator="horizontal" />
handlerSelection(details) { var self = this; self.rowIndex = details.keys[0]; // the index is not obtained },
Thanks in advance
-
Wouldn’t it be CompanyID? So
details.CompanyID
?Scott
-
-
You can’t. Row index has been taken out.
Scott
-
I used the row index, to eliminate
self.dataTable.splice(self.rowIndex , 1);
now, my pages no work.
can you give me some ideas to help me
Thanks in advance
-
I tried this way and it works, my question is if it is correct or are there other more efficient ways
handlerSelection(details) { var self = this; let i = self.dataTable.map(item => item.id).indexOf(details.keys[0]) self.rowIndex = i ; }
-
I have no idea. Sorry. If it works, great. But, it should be sending your data row in
details
and you should be able to work with your own ID to find your data and work with it as you need to. Thing is, the row index will change, if the user reorders or filters (if you have those features in use) the table. That’s why you should work with your own data id field and not the row index of the table.Scott