Home > front end >  In the form of ivew unchecking the checkbox when deleting rows
In the form of ivew unchecking the checkbox when deleting rows

Time:12-11

Project in a form, with iview, this table column 1 is a checkbox, we want to implement a function: user uncheck a record of the checkbox, the program automatically deleted, this implementation is simpler, but there is a problem is the next line was originally has been checked, the current row is deleted after the location of the next line up, then will be displayed for this option, the code is as follows:

 & lt; Input type='checkbox' v - model='item. IsChecked' @ change='switchBillSelected (item)' & gt;  

SwitchBillSelected (item) {
if (! Item. IsChecked) {
For (the let I=0; iIf (this. Bills [I] id==item. Id) {
This. Bills. Splice (I, 1)
break;
}
}
}
}


In order to solve this problem, I changed the code above, to bind data, under forced to refresh the form:

 & lt; Input type='checkbox' v - model='item. IsChecked' @ change='switchBillSelected (item)' & gt;  

SwitchBillSelected (item) {
if (! Item. IsChecked) {
For (the let I=0; iIf (this. Bills [I] id==item. Id) {
This. Bills. Splice (I, 1)
break;
}
}

//Keep an alias of enclosing bills
Let alias=this. Bills;

//Re - bind this. Bills to refresh the check the status of the visible rows
This. Bills=[];
SetTimeout ((bills)=& gt; {
This. Bills=bills;
}, 500, alias)
}
}


This is really useful, but forced to refresh the entire form to less elegant, part one is the form will be flashing once, the second, it is actually around the question, is there a better way?

CodePudding user response:

Iview form?
  • Related