How to create validator for editable grid

1
0
-1

Good day,

I have an editable grid which I use to enter prices (e.g. 1000.99, 999.01). I would like to have a validator to check if the entered data is a number or not.

I tried creating a validator with type double numeric, float numeric, long numeric or short numeric but it didn't work.

Please help on how to do validation for the cells in the activity grid.

Thanks in advance.

Comments

Submitted by florine.boudin on Fri, 02/07/2014 - 16:51

Hi alfred.ayson,

To investigate on your trouble, can you precise the version of the Studio you are using ? 5.x or 6.x ?

Submitted by alfred.ayson on Mon, 02/10/2014 - 02:08

I used the General > Validators > Add... options (validator type) provided in bonita community 6.2.1 when the editable grid widget is selected

2 answers

1
+2
-1

Hi alfred.ayson,

Hello alfred.ayson,

On a 6.x version of the Bonita BPM Studio, I suggest you to use a Groovy Expression for your validation.

The existing numeric validator are useful for simple widget, but the editable grid return multiple values.

In the General> Validators>Add... , use the follow properties of you validator :

- Validator Type : select the 'Groovy expression'

- Error message : don't forget to fill this mandatory field.

- Parameter : edit a Script (Groovy Script) and here is an example of code to validate that all the entered data are numbers

  1. for( Object raw : field_Editable_grid1 ){<br />
  2. for( Object s : (List<Object>) raw ){<br />
  3. if(!((String)s).matches("^-?[0-9]+(\\.[0-9]+)?\$")){<br />
  4. return false;<br />
  5. }<br />
  6. }<br />
  7. }<br />

This code is a quick example, modify it for your own need.

Comments

Submitted by alfred.ayson on Tue, 02/11/2014 - 02:28

I will try this approach and will post again once my problem is resolved.

thank you very much!!!

1
+1
-1

share your code i will check that where you have problem.

Comments

Submitted by alfred.ayson on Mon, 02/10/2014 - 02:04

I didn't use code expression for this...I only used the General > Validators > Add... options (validator type) provided in bonita community 6.2.1 when the editable grid widget is selected

Notifications