[Solved] Q-Input Internal validation: How to pass parameter
-
Dear,
I did a demo, please see the link.
https://codepen.io/Stanley-549393092/pen/GRpGZrR?editors=1010There are two checks in the table. One is the mandatory input check, the other is duplicate check. For example, if user input customer number 1000 first time and he input it again in the second line, it will throw error message.
Currently, I stuck at method vduplicate. Could you please have a look, thanks! -
Not sure I understand your need, but if you just want to check for duplicates, just do something like this in your
vduplicate
methodvduplicate(val) { if (this.results.filter(v => v.customer === val).length > 1) { return "Duplicate !" } }
But, to answer your question
Q-Input Internal validation: How to pass parameter
you can use this :
... :rules = "[ val => vduplicate(val, props.rowIndex) ] ... vduplicate(val, rowIndex) { // ... }
-
@tof06
Thanks a lot! Not only answer the question, but also give better solution.
The code is adjusted. But now I have another question, could you please have a look of method updateItemCell? -
@Stanley said in Q-Input Internal validation: How to pass parameter:
But now I have another question, could you please have a look of method updateItemCell
What is your problem with this method ?
Unless you only want to update your data on
change
, you even don’t need this method. You can just usev-model=props.row.customer
instead of:value=props.row.customer
with associatedchange
event. -
@tof06
Considering the performance issue, I think it has to use @change event, or else it will call Rest API (get customer info) every time when user input.And for the second part which is my question, if user input duplicate customer id, it should not call Rest API.
For example,
For the first line, user input customer id AAA, it will call API only once and returns the customer info.
For the second line, user input customer id AAA again, it will throw the duplicate error message. And in my program, it still calls Rest API. But from my point of view, there is no necessary to call API.Thanks a lot for your help!
-
@tof06
I fixed it by myself and the code was adjusted. It is very simple, I just wonder why I did not figure it out that time.
Still thanks a lot for your help!