Results 1 to 5 of 5

Thread: Local field validation

  1. #1

    Join Date
    Aug 2007
    Location
    Romania
    Posts
    41

    Default Local field validation

    Hi Guys,

    I searched the forum for this, but didn't find an exact answer. Can anybody give me an exact answer?

    I have a grid, then in the toolbar an Add buton. when I press this button, a form is opened in an ExtJS window, here i want to make some valisations, ex. check if name field value already exist in the datastore.

    I hope you understand what i'm trying to do...

    Thanks in advance.

  2. #2
    Sencha User catacaustic's Avatar
    Join Date
    Jul 2007
    Location
    "A Land Down Under"
    Posts
    618

    Default

    To do something like this I think the best thing to do is set up a handler on the form fields that will do a call back to the server asking if the value is unique or not. If that will do what you want it too, look at the Ext.data.Connection () docs and you'll see how to do it as a background process.

    If you're just concerned about duplications in the local data store then you can just search through the fields in each of the records to find if there's any duplicates. I don't think that there's a function to do this at the moment, but it's not hard to implement something like that.
    'Once again, fortune vomits on my eiderdown'
    - Edmund Blackadder

  3. #3

    Join Date
    Aug 2007
    Location
    Romania
    Posts
    41

    Default

    Quote Originally Posted by catacaustic View Post
    To do something like this I think the best thing to do is set up a handler on the form fields that will do a call back to the server asking if the value is unique or not. If that will do what you want it too, look at the Ext.data.Connection () docs and you'll see how to do it as a background process.

    If you're just concerned about duplications in the local data store then you can just search through the fields in each of the records to find if there's any duplicates. I don't think that there's a function to do this at the moment, but it's not hard to implement something like that.
    Hi catacaustic

    Thanks for your reply.
    The first solution i don't like, I don't want to make to many requests to the server, i want to do the validation locally. Searching through the data store for duplicates, is what i want to do. Unfortunately i'm not an expert in JS, can you give me some more data, or even a starting example....

    Many thanks

  4. #4
    Ext JS Premium Member
    Join Date
    Mar 2007
    Posts
    173

    Default validator

    The form fields have a "validator" config option. (and lots of related validation configs). This specifies a function that is called when the field is validated and returns true or false. Hence all done locally.

    You would need to write the specific validation code to check if the name already exists in the data store, but shouldn't be difficult.

    There are several examples of "standard" validation functions in the examples part of the forum that might help.

    Max

  5. #5

    Join Date
    Aug 2007
    Location
    Romania
    Posts
    41

    Default

    Quote Originally Posted by MaxT View Post
    The form fields have a "validator" config option. (and lots of related validation configs). This specifies a function that is called when the field is validated and returns true or false. Hence all done locally.

    You would need to write the specific validation code to check if the name already exists in the data store, but shouldn't be difficult.

    There are several examples of "standard" validation functions in the examples part of the forum that might help.

    Max
    Hi MaxT,

    I was meaning searching the data store locally for duplicate value of let's say the name field, i know validation, i even tried it but I don't know how to search the datastore for duplicates, I tried ds.filter, but this seams to affect my datagrid. The validation that i want, has to be done while typing, on key up. It has to search the data store if the name typed in exists in the data store.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •