1. #1
    Sencha User
    Join Date
    Sep 2011
    Location
    Taiwan
    Posts
    99
    Answers
    1
    Vote Rating
    2
    cwtuan is on a distinguished road

      0  

    Default Unanswered: Apply decodeURIComponent() for every AJAX response

    Unanswered: Apply decodeURIComponent() for every AJAX response


    Hi,
    For some reason, we have to encode Chinese characters in unicode at server side.
    But when loading a grid, I have to decode all of them again. An Example is shown below.
    PHP Code:
    columns : [  {
            
    dataIndex 'name',
            
    renderer : function(value) {
                return 
    decodeURIComponent(value);
            }
        },{
            
    dataIndex 'address',
            
    renderer : function(value) {
                return 
    decodeURIComponent(value);
            }
        }

    Is it possible to apply decodeURIComponent() for every AJAX response by default so that I don't have to write decodeURIComponent() for every grid column?

    Many thanks!
    Tony

  2. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    Try to apply decoding at model definition by using field convert().

  3. #3
    Sencha User
    Join Date
    Sep 2011
    Location
    Taiwan
    Posts
    99
    Answers
    1
    Vote Rating
    2
    cwtuan is on a distinguished road

      0  

    Default


    Quote Originally Posted by vietits View Post
    Try to apply decoding at model definition by using field convert().
    Hi, vietits
    Thanks for your reply!
    This method still needs to implement a converter for each model field.
    It would be better if we can apply decodeURIComponent() for all Ext.Ajax's response so that we don't have to do the dirty job.
    Thanks!

  4. #4
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    If so, you can listen for 'requestcomplete' event from Ext.Ajax:
    Code:
    Ext.Ajax.on('requestcomplete', function(connection, response, options){
        // your code here
    });

Thread Participants: 1

Tags for this Thread