Validate grid items against drop down values.

Hello guys,

            I've an interface where I need to validate a grid items added by user in a gridfield and once they submit they become available for selection in the dropdown on the same interface where once they select the item they can submit finally.

 

            Has anyone ever had tried validating add/removable grid items against the existing dropdown (populated by the same gridfield) to make sure they do not enter the "duplicate" values?

 

Thanks,

Nick

  Discussion posts and replies are publicly visible

Parents
  • Nick,

    On the entry form, where they need to add new items, I would add a validation to ensure that the entered value is not already existing in the DB. On "Submit", I would query the DB for the item name, and if the totalcount of the resulting datasubset is greater than 0, then return an error message to the user indicating that an item with that name already exists. Depending on the number of values in the DB and performance constraints, you could use a simpler, but less performant method of querying for all existing items on page load, and on "Keypress" find the entered value within the existing list. If a match is found, return a similar error message.

    If you need additional support, please post your code, and we can provide more concrete code suggestions, but this is the method I would use to validate the entered values.
  • Hello Ashvin, thanks for you suggestion. But we've an issue with the querying on the db side, it'll make the interface slower. My instructions are to validate the gridfield inputs against the dropdown component. the setup of the page isn't that complex, it's just a selection of a radio button that loads the grid, if there are no existing items they may be added, those items when the 'Update' button is pressed are visible as dropdown ChoiceValues and the user can then select the value they may choose to finally 'submit'.
Reply
  • Hello Ashvin, thanks for you suggestion. But we've an issue with the querying on the db side, it'll make the interface slower. My instructions are to validate the gridfield inputs against the dropdown component. the setup of the page isn't that complex, it's just a selection of a radio button that loads the grid, if there are no existing items they may be added, those items when the 'Update' button is pressed are visible as dropdown ChoiceValues and the user can then select the value they may choose to finally 'submit'.
Children