Announcement

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

    Using ListGrid.FilterEditor with a validator

    I am using SmartClient_v91p_2014-04-30_PowerEdition and I need to apply a regexp validator on one of the ListGridFields, the validator works and points out invalid expressions, but when either the filterButton is clicked or Enter key is pressed it still attempts to filter eventually resulting in an error, I need the filter function to not execute when validation fails.

    this is the validator on the ListGridField's filterEditorProperties:

    Code:
    validators: [
    	{
    	   type: "regexp",
    	   expression: /^(<|>|=|<=|>=)?(?!-0(\.0+)?$)-?([1-9]\d*|0){1}(\.\d+)?$|^(?!-0(\.0+)?\.\.\.)-?([1-9]\d*|0){1}(\.\d+)?\.\.\.(?!-0(\.0+)?$)-?([1-9]\d*|0){1}(\.\d+)?$/,
    	   errorMessage: "Expressão inválida",
               stopOnError:true
    	}
    ],
    validateOnExit: true
    Last edited by mrisoli; 12 May 2014, 06:41.

    #2
    Validators are not applied to filter criteria in general, because filter criteria do not in general represent valid values for a field. Think of filtering by partial zip code, for example.

    If you get criteria that is an invalid regexp in your server code, just signal a general failure (status = -1) and send a clear error message back to the user - the user will see it in a modal dialog.

    Comment

    Working...
    X