How to get selected rows' index in Table element in iview vue?











up vote
0
down vote

favorite












How to get selected rows' index in Table element in iview vue?
For example, table element is like below:



<Table ref="selection" :columns="columns4" :data="data1" @on-selection-change="updateSelectedNumber"></Table>









share|improve this question
























  • is it using some framework to issue the table?
    – Hamilton Gabriel
    Nov 15 at 1:59










  • @HamiltonGabriel yes, I'm using Vue and iView.
    – chucklai
    Nov 15 at 2:01















up vote
0
down vote

favorite












How to get selected rows' index in Table element in iview vue?
For example, table element is like below:



<Table ref="selection" :columns="columns4" :data="data1" @on-selection-change="updateSelectedNumber"></Table>









share|improve this question
























  • is it using some framework to issue the table?
    – Hamilton Gabriel
    Nov 15 at 1:59










  • @HamiltonGabriel yes, I'm using Vue and iView.
    – chucklai
    Nov 15 at 2:01













up vote
0
down vote

favorite









up vote
0
down vote

favorite











How to get selected rows' index in Table element in iview vue?
For example, table element is like below:



<Table ref="selection" :columns="columns4" :data="data1" @on-selection-change="updateSelectedNumber"></Table>









share|improve this question















How to get selected rows' index in Table element in iview vue?
For example, table element is like below:



<Table ref="selection" :columns="columns4" :data="data1" @on-selection-change="updateSelectedNumber"></Table>






vue.js html-table iview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 at 11:03









Brian Tompsett - 汤莱恩

4,1631336100




4,1631336100










asked Nov 15 at 1:57









chucklai

1911311




1911311












  • is it using some framework to issue the table?
    – Hamilton Gabriel
    Nov 15 at 1:59










  • @HamiltonGabriel yes, I'm using Vue and iView.
    – chucklai
    Nov 15 at 2:01


















  • is it using some framework to issue the table?
    – Hamilton Gabriel
    Nov 15 at 1:59










  • @HamiltonGabriel yes, I'm using Vue and iView.
    – chucklai
    Nov 15 at 2:01
















is it using some framework to issue the table?
– Hamilton Gabriel
Nov 15 at 1:59




is it using some framework to issue the table?
– Hamilton Gabriel
Nov 15 at 1:59












@HamiltonGabriel yes, I'm using Vue and iView.
– chucklai
Nov 15 at 2:01




@HamiltonGabriel yes, I'm using Vue and iView.
– chucklai
Nov 15 at 2:01












1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










GET data rows item clicked.
To get the index of the item clicked, simply click on the line you want, not above the checkbox, over the item that is not the box, but that is on the same line.



add this tag



methods: {
valueRowClick(value)
console.log(value)
}
result:
position: 0 -> Object
position 1: -> Index item clicked 2


When you select an item, according to the documentation it throws the value of the selected items out.
GET data item select



<table @on-select="nameFunction">
methods: {
nameFunction (value) {
console.log(value)
}
}


DELETE ITEM EXAMPLE:
add the this tag TABLE



<table @on-selection-change="valueItemsSelected"></table>
methods: {
valueItemsSelected(value){
if(value.length > 0){
for(let y = 0, max1 = value.length; y < max1; y ++){
for(let i = 0, max = this.data1.length; i < max; i++){
if(value[y] === this.data1[i]) {
this.data1.splice(i, 1)
}
}
}
}
}
},





share|improve this answer























  • Actually I want to do batch deletion. After selecting rows, I want to delete them one by one. It is complicated to maintain an additional array of selected tags. Is there any other more convenient way to accomplish it ?
    – chucklai
    Nov 15 at 2:18










  • No it's not, I'll edit my answer with an example of the requested one. I showed the example of how to get the index.
    – Hamilton Gabriel
    Nov 15 at 2:22










  • i Add @chucklai
    – Hamilton Gabriel
    Nov 15 at 2:32










  • there maybe a little misunderstanding. I want to delete selected rows whose checkbox is checked without knowing the actually ID or other attributes.
    – chucklai
    Nov 15 at 2:41










  • a moment for kindness
    – Hamilton Gabriel
    Nov 15 at 2:46











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311349%2fhow-to-get-selected-rows-index-in-table-element-in-iview-vue%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










GET data rows item clicked.
To get the index of the item clicked, simply click on the line you want, not above the checkbox, over the item that is not the box, but that is on the same line.



add this tag



methods: {
valueRowClick(value)
console.log(value)
}
result:
position: 0 -> Object
position 1: -> Index item clicked 2


When you select an item, according to the documentation it throws the value of the selected items out.
GET data item select



<table @on-select="nameFunction">
methods: {
nameFunction (value) {
console.log(value)
}
}


DELETE ITEM EXAMPLE:
add the this tag TABLE



<table @on-selection-change="valueItemsSelected"></table>
methods: {
valueItemsSelected(value){
if(value.length > 0){
for(let y = 0, max1 = value.length; y < max1; y ++){
for(let i = 0, max = this.data1.length; i < max; i++){
if(value[y] === this.data1[i]) {
this.data1.splice(i, 1)
}
}
}
}
}
},





share|improve this answer























  • Actually I want to do batch deletion. After selecting rows, I want to delete them one by one. It is complicated to maintain an additional array of selected tags. Is there any other more convenient way to accomplish it ?
    – chucklai
    Nov 15 at 2:18










  • No it's not, I'll edit my answer with an example of the requested one. I showed the example of how to get the index.
    – Hamilton Gabriel
    Nov 15 at 2:22










  • i Add @chucklai
    – Hamilton Gabriel
    Nov 15 at 2:32










  • there maybe a little misunderstanding. I want to delete selected rows whose checkbox is checked without knowing the actually ID or other attributes.
    – chucklai
    Nov 15 at 2:41










  • a moment for kindness
    – Hamilton Gabriel
    Nov 15 at 2:46















up vote
0
down vote



accepted










GET data rows item clicked.
To get the index of the item clicked, simply click on the line you want, not above the checkbox, over the item that is not the box, but that is on the same line.



add this tag



methods: {
valueRowClick(value)
console.log(value)
}
result:
position: 0 -> Object
position 1: -> Index item clicked 2


When you select an item, according to the documentation it throws the value of the selected items out.
GET data item select



<table @on-select="nameFunction">
methods: {
nameFunction (value) {
console.log(value)
}
}


DELETE ITEM EXAMPLE:
add the this tag TABLE



<table @on-selection-change="valueItemsSelected"></table>
methods: {
valueItemsSelected(value){
if(value.length > 0){
for(let y = 0, max1 = value.length; y < max1; y ++){
for(let i = 0, max = this.data1.length; i < max; i++){
if(value[y] === this.data1[i]) {
this.data1.splice(i, 1)
}
}
}
}
}
},





share|improve this answer























  • Actually I want to do batch deletion. After selecting rows, I want to delete them one by one. It is complicated to maintain an additional array of selected tags. Is there any other more convenient way to accomplish it ?
    – chucklai
    Nov 15 at 2:18










  • No it's not, I'll edit my answer with an example of the requested one. I showed the example of how to get the index.
    – Hamilton Gabriel
    Nov 15 at 2:22










  • i Add @chucklai
    – Hamilton Gabriel
    Nov 15 at 2:32










  • there maybe a little misunderstanding. I want to delete selected rows whose checkbox is checked without knowing the actually ID or other attributes.
    – chucklai
    Nov 15 at 2:41










  • a moment for kindness
    – Hamilton Gabriel
    Nov 15 at 2:46













up vote
0
down vote



accepted







up vote
0
down vote



accepted






GET data rows item clicked.
To get the index of the item clicked, simply click on the line you want, not above the checkbox, over the item that is not the box, but that is on the same line.



add this tag



methods: {
valueRowClick(value)
console.log(value)
}
result:
position: 0 -> Object
position 1: -> Index item clicked 2


When you select an item, according to the documentation it throws the value of the selected items out.
GET data item select



<table @on-select="nameFunction">
methods: {
nameFunction (value) {
console.log(value)
}
}


DELETE ITEM EXAMPLE:
add the this tag TABLE



<table @on-selection-change="valueItemsSelected"></table>
methods: {
valueItemsSelected(value){
if(value.length > 0){
for(let y = 0, max1 = value.length; y < max1; y ++){
for(let i = 0, max = this.data1.length; i < max; i++){
if(value[y] === this.data1[i]) {
this.data1.splice(i, 1)
}
}
}
}
}
},





share|improve this answer














GET data rows item clicked.
To get the index of the item clicked, simply click on the line you want, not above the checkbox, over the item that is not the box, but that is on the same line.



add this tag



methods: {
valueRowClick(value)
console.log(value)
}
result:
position: 0 -> Object
position 1: -> Index item clicked 2


When you select an item, according to the documentation it throws the value of the selected items out.
GET data item select



<table @on-select="nameFunction">
methods: {
nameFunction (value) {
console.log(value)
}
}


DELETE ITEM EXAMPLE:
add the this tag TABLE



<table @on-selection-change="valueItemsSelected"></table>
methods: {
valueItemsSelected(value){
if(value.length > 0){
for(let y = 0, max1 = value.length; y < max1; y ++){
for(let i = 0, max = this.data1.length; i < max; i++){
if(value[y] === this.data1[i]) {
this.data1.splice(i, 1)
}
}
}
}
}
},






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 15 at 3:03

























answered Nov 15 at 2:09









Hamilton Gabriel

965




965












  • Actually I want to do batch deletion. After selecting rows, I want to delete them one by one. It is complicated to maintain an additional array of selected tags. Is there any other more convenient way to accomplish it ?
    – chucklai
    Nov 15 at 2:18










  • No it's not, I'll edit my answer with an example of the requested one. I showed the example of how to get the index.
    – Hamilton Gabriel
    Nov 15 at 2:22










  • i Add @chucklai
    – Hamilton Gabriel
    Nov 15 at 2:32










  • there maybe a little misunderstanding. I want to delete selected rows whose checkbox is checked without knowing the actually ID or other attributes.
    – chucklai
    Nov 15 at 2:41










  • a moment for kindness
    – Hamilton Gabriel
    Nov 15 at 2:46


















  • Actually I want to do batch deletion. After selecting rows, I want to delete them one by one. It is complicated to maintain an additional array of selected tags. Is there any other more convenient way to accomplish it ?
    – chucklai
    Nov 15 at 2:18










  • No it's not, I'll edit my answer with an example of the requested one. I showed the example of how to get the index.
    – Hamilton Gabriel
    Nov 15 at 2:22










  • i Add @chucklai
    – Hamilton Gabriel
    Nov 15 at 2:32










  • there maybe a little misunderstanding. I want to delete selected rows whose checkbox is checked without knowing the actually ID or other attributes.
    – chucklai
    Nov 15 at 2:41










  • a moment for kindness
    – Hamilton Gabriel
    Nov 15 at 2:46
















Actually I want to do batch deletion. After selecting rows, I want to delete them one by one. It is complicated to maintain an additional array of selected tags. Is there any other more convenient way to accomplish it ?
– chucklai
Nov 15 at 2:18




Actually I want to do batch deletion. After selecting rows, I want to delete them one by one. It is complicated to maintain an additional array of selected tags. Is there any other more convenient way to accomplish it ?
– chucklai
Nov 15 at 2:18












No it's not, I'll edit my answer with an example of the requested one. I showed the example of how to get the index.
– Hamilton Gabriel
Nov 15 at 2:22




No it's not, I'll edit my answer with an example of the requested one. I showed the example of how to get the index.
– Hamilton Gabriel
Nov 15 at 2:22












i Add @chucklai
– Hamilton Gabriel
Nov 15 at 2:32




i Add @chucklai
– Hamilton Gabriel
Nov 15 at 2:32












there maybe a little misunderstanding. I want to delete selected rows whose checkbox is checked without knowing the actually ID or other attributes.
– chucklai
Nov 15 at 2:41




there maybe a little misunderstanding. I want to delete selected rows whose checkbox is checked without knowing the actually ID or other attributes.
– chucklai
Nov 15 at 2:41












a moment for kindness
– Hamilton Gabriel
Nov 15 at 2:46




a moment for kindness
– Hamilton Gabriel
Nov 15 at 2:46


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311349%2fhow-to-get-selected-rows-index-in-table-element-in-iview-vue%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?