Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Problem with dependent selects example in Showcase

    We're trying to accomplish what is shown in this showcase example using the Remote Data version. It works well when editing a new record, but when editing an existing record, if you change the Category, the previously selected Item remains and you can save the change. You aren't forced to reselect the item.

    How can we clear the previously selected Item and force the user to select an Item in the new Category?

    #2
    A call to clearEditValue() would do this. Or, to set a specific value, a call to setEditValue() would do this.

    Comment


      #3
      The showcase example is calling clearEditValue(), but that does not force the user to select a new value, it just reverts to the previous value upon saving the record.

      Comment


        #4
        What do you mean by "force" in this case?

        If you want a validation error to be shown, you should have your server code return such an error.

        Comment


          #5
          I was hoping for some way to clear the value from the related select, meaning set it's new value to null. It has a required="true" validator on the field already. If I could nullify the selection the user would have to make a new selection before saving.

          Unfortunately clearEditValue() appears to clear the value, but in effect it must be marked as no longer changed since when the record is saved that field is not updated and the previously selected value remains. I've tried setting is to an empty string with the same effect. There doesn't appear to be a way to actually set it to a new NULL value.

          I can add a server side method to validate but was hoping to avoid that since it is not a simple referential integrity check in this case.

          Comment


            #6
            clearEditValue() would indeed just reset the field as though it had never been edited. However explicitly setting the value to "" should result in the failure of the "required" validator. However, a call to validateRow() may be required since you are making changes to user-entered data outside of the usual cycle of focusing in the cell, interacting, and leaving the cell.

            Comment


              #7
              I've tried validateRow() and it still doesn't flag the field with an error. If I save the row it behaves the same as clearEditValue(), in other words, the row is saved and the field reverts to it's previous value as if no change was made.

              Comment


                #8
                We seem to be getting the expected behavior. Here are all the moving parts in the solution we're proposing - it won't work if any part of this is missing:

                1. the field must be "required" / have a Required validator

                2. you must setEditValue() to the empty string (so the required validator will fail)

                3. validateRow() may need to be called depending on your settings for editing by cell

                Comment


                  #9
                  Thanks. I've got it working now.

                  Comment

                  Working...
                  X