No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    [Solved] Q-Input Internal validation: How to pass parameter

    Framework
    2
    6
    789
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Stanley last edited by Stanley

      Dear,

      I did a demo, please see the link.
      https://codepen.io/Stanley-549393092/pen/GRpGZrR?editors=1010

      There 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!

      1 Reply Last reply Reply Quote 0
      • T
        tof06 last edited by tof06

        @Stanley

        Not sure I understand your need, but if you just want to check for duplicates, just do something like this in your vduplicate method

        vduplicate(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) {
         // ...
        }
        
        1 Reply Last reply Reply Quote 0
        • S
          Stanley last edited by

          @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?

          T 1 Reply Last reply Reply Quote 0
          • T
            tof06 @Stanley last edited by

            @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 use v-model=props.row.customer instead of :value=props.row.customer with associated change event.

            1 Reply Last reply Reply Quote 0
            • S
              Stanley last edited by Stanley

              @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!

              1 Reply Last reply Reply Quote 0
              • S
                Stanley last edited by

                @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!

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post