Announcement

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

    Validation not working using optionDataSource

    Hi Isomorphic ,
    I am trying to apply validation on a listgrid field. The list grid is created by batchuploader. Below is the mapping in my ds.xml
    Code:
        <field name="myName" title="MyName" type="text"
                optionDataSource="myOptionDS" displayField="myDisplayField"
                valueField="myValueField" autoFetch="true" />
    The list grid gets loaded with the data. On click of this field , it generates the correct drop down with right values from the optionDataSource but the validation does not work.
    If the selected value from batchuploder file is not one of the values in dropdown it should show validation error. Its not working.

    What I tried :
    1. I tried type="enum" in the above xml tag.
    2. Tried type="text" and editorType="select".

    Also autofetch=true is not working on this. When I click the dropdown ,only then the request is sent to populate dropdown. I need the values from server at the time when listgrid is created and then the validations on client side.

    Any suggestions?

    Thanks in advance.
    Last edited by preeti_kanyal; 27 Oct 2018, 05:36.

    #2
    Since you have not declared any validators, validation would not be expected to occur.

    Please take a look at the available validator types and declare one. It's likely that you want "hasRelatedRecord".

    Comment


      #3
      HI Isomorphic ,
      Thanks for the response. My requirement is to fetch the data from server to form a dropdown. And the selected value can only be out of these values. Batchuploader can render data from csv with invalid data , so it should show error.
      If I do setValueMap statically with type enum then the validation works as expected but our requirment is to populate the list from server.

      1. Populate grid from csv with the validation error.
      2. All the dropdowns should be populated with dynamic data from server (Done)
      2. Run the client side validations when user update any data.
      Last edited by preeti_kanyal; 28 Oct 2018, 22:57.

      Comment


        #4
        Declaring a field as type "enum" with a valueMap constrains it's value. Just declaring an optionDataSource does not and should not do so, and we've already explained how to add validation against the related DataSource if you want.

        Comment


          #5
          Note further than with an optionDataSource, validation won't be client-side, as the data for the optionDataSource is normally not completely loaded, thus requiring a trip to the server.

          Comment


            #6
            Thanks Isomorphic ,
            I wrote a custom validator on server side and configured the same in ds.xml and I was able to achieve my functionality. Thanks for the support.

            Comment


              #7
              Hi preeti_kanyal,

              as you are talking about BatchUploader and foreignKeys I'd like to make sure you know about importStrategy which can be used to do a Text->ID resolution in BatchUploader in order to save ID values later on (allowing a normalized table structure). See these threads leading to the feature.

              Best regards
              Blama

              Comment

              Working...
              X