1. #21
    Ext User
    Join Date
    Jun 2007
    Posts
    187
    Vote Rating
    1
    anjelika is on a distinguished road

      0  

    Default


    Hello,
    Nice addon!
    I have a (noob) question.
    How do I interpret the response from AJAX?
    e.g my app returns {success: true, valid: false, reason:'undefined error'}
    How can I process the response in my success(response, options){} function (or should I process it some place else?)?
    I know that using "response.responseText" it shows the whole message ({success: true, valid: false, reason:'undefined error'}), all I want to do is to break the values apart (e.g. test the validation).
    Thanks

  2. #22
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,557
    Vote Rating
    383
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    You do not need to do anything because that text is displayed same way as any other invalid text (tooltip, side icon or bellow the field).
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  3. #23
    Ext User
    Join Date
    Jun 2007
    Posts
    187
    Vote Rating
    1
    anjelika is on a distinguished road

      0  

    Default


    Hello,
    Thanks for the prompt reply.
    I got the ideea behing this plugin but here's what I need to do:

    1. enter an ID in an input box.
    2. the id is searched in background (using ajax provided by your plugin) to match a record in a database (php server side).
    3. if a record is found I need to return the data associated with that record that is loaded into a form (the one containing the ID field also).

    Now, here is how I am thinking to do that (I am open to suggestions)
    1. when the ID field is modified the request is triggered and performs the background check to the database.
    2. if the ID is found, I return the {success: true, valid: true} response.
    Can I return the collected data into this response also? That will save me some steps (e.g. {success: true, valid: true, results:[{name: xxx, address:yyy, phone: zzz}] ???
    3. If I can't return the collected data into the previous request together with the ajax response I have to populate the form fields (by using for.load('url...')), that's why I need to process the response from your plugin by myself.
    Tho, I am not sure how to do that..here;s some sample code:

    var id = new Ext.texfield{[
    ....
    ....
    plugin: [RemoteValidation...]
    rvOptions: { url:'validate.php', success:function(response, options){ if (response.valid == true) form.load('url')}

    The underline function is my unsolved problem
    Is there another better place to process the response and proceed accordingly that the success function?
    Thanks for your time

  4. #24
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,557
    Vote Rating
    383
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    Well, this is validationplugin and it's basic purpose is field validation. You could put your callback function to rvOptions and you could implement the functionality you describe in that callback but it seem quite awkward and overcomplicated to me.

    The straightforward solution would be to listen to field's keyup event (or an another one), send request and process result. If you need this functionality in more than one form, create an extended class for it.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  5. #25
    Sencha User
    Join Date
    Oct 2007
    Posts
    57
    Vote Rating
    0
    pludikhu is on a distinguished road

      0  

    Default onBlur added

    onBlur added


    Saki

    You said it was OK to add some functions, right?! Here's one I wanted to share, might not mean a lot to you pro's but perhaps for some newbies like me ...

    My requirement was e.g. filling in several e-mail addresses in one field and having that checked by the server. But with the 500 milliseconds delay, one could hardly type anything in the field without the server validation firing (whenever a slow user hesitated or so).

    So I set the delay to a higher value but then wanted to have the remote validation fire immediately on blur.

    Therefore I changed the event handling as follows:
    Code:
    		// install event handlers on field render
    		field.on({
    			render:{single:true, scope:field, fn:function() {
    				this.remoteValidationTask = new Ext.util.DelayedTask(this.validateRemote, this);
    				this.el.on('keyup', this.filterRemoteValidation, this);
    			}},
    			blur:{single:false, scope:field, fn:function() {
    				this.validateRemote();
    				this.remoteValidationTask.cancel();
    			}}
    		});
    The last line (this.remoteValidationTask.cancel(); ) for those who don't know why: is to cancel the delayed keyup event.

    Good checking to all ;-)

    Patrick

  6. #26
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,557
    Vote Rating
    383
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    Looks good!

    Have you thoroughly tested it if it doesn't break anything? If yes I'd add it to the main stream - I like the idea.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  7. #27
    Sencha User
    Join Date
    Oct 2007
    Posts
    57
    Vote Rating
    0
    pludikhu is on a distinguished road

      0  

    Default Now that's an other matter

    Now that's an other matter


    I did indeed test it, Saki.
    It looks OK in my test configuration. Firebug doesn't complain.
    But then again, I'm a total noob in JS programming so I'm afraid you cannot take my word for it, sorry.
    But it looks pretty straightforward doesn't it?!

    Patrick

  8. #28
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,557
    Vote Rating
    383
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    Yeah, just you don't need single:false - it's default but that's just cosmetics.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  9. #29
    Sencha User
    Join Date
    Feb 2008
    Posts
    21
    Vote Rating
    0
    omegafox is on a distinguished road

      0  

    Default


    is it possible to use this plugin for cross validations with two date fields and numberfields?

  10. #30
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,557
    Vote Rating
    383
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    You would need to patch it somehow as the design concept is per-field validation. In another words, only the field name/value is posted to the server for validation.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM