Results 1 to 3 of 3

Thread: Databind problema using ajax proxy

  1. #1
    Sencha User
    Join Date
    Aug 2017
    Location
    Brazil
    Posts
    5

    Default Databind problema using ajax proxy

    Hello people good night,
    I am having problems using the databinding, I need to load my form using ajax proxy, if I put the fixed data works, however if I use the store with ajax proxy the form does not receive the data.

    data1.json

    Code:
    {
        "success": true,
        "total": "1",
        "testes": [{
                        "CORRETOR_ID": "24",
                        "NOME": "WAGNER NOGUEIRA",
                        "CPF": "12345678901",
                        "RG": null,
                        "PASSAPORTE": null,
                        "ENDERECO": "RUA TESTE",
                        "NUMERO": "100",
                        "COMPLEMENTO": "SL 101",
                        "BAIRRO": "TESTE",
                        "CEP": "12345-678",
                        "CIDADE": "TESTE",
                        "ESTADO": "11",
                        "NATURALIDADE": null,
                        "TELEFONE": "21 1234-56789",
                        "CELULAR": null,
                        "PROFISSAO_ID": "996",
                        "EMAIL": "[email protected]",
                        "DATA_NASCIMENTO": "05\/01\/1980",
                        "DATA_CADASTRO": "2017-12-06 20:09:28",
                        "STATUS": "A",
                        "ORGAO_ID": "2",
                        "ORGAO_ESTADO_ID": "7",
                        "ORGAO_NUMERO": "102030",
                        "CODIGO_PLANO": "1",
                        "VALOR_PLANO": "86,40",
                        "METODO_PAGAMENTO": "CREDIT_CARD",
                        "ORGAO": "CRECI",
                        "PROFISSAO": "CORRETOR",
                        "VALOR_PLANO_ORIGINAL": "8640",
                        "UF_SIGLA": "MG",
                        "PROXIMA_FATURA": null,
                        "CODE": "1",
                        "PARCELAS": "1 parcela",
                        "AMOUNT": "8640",
                        "PLANO": ""
                }]
    }
    Working
    Code:
     Ext.define('Myapp.view.TestesViewModel', {
                extend: 'Ext.app.ViewModel',
                alias: 'viewmodel.testes',
    
    
                /*  stores: {
                      corretores: {
                          autoLoad: true,
                          autoSync: true,
                          model: 'Myapp.model.cadastro.Teste',
                          proxy: {
                              type: 'ajax',
                              api: {
                                  read: 'data1.json'
                              },
                              reader: {
                                  type: 'json',
                                  rootProperty: 'testes'
                              }
                          }
                      }
                  }
                */
    
    
                data: {
                    "CORRETOR_ID": "24",
                    "NOME": "WAGNER NOGUEIRA",
                    "CPF": "12345678901",
                    "RG": null,
                    "PASSAPORTE": null,
                    "ENDERECO": "RUA TESTE",
                    "NUMERO": "100",
                    "COMPLEMENTO": "SL 101",
                    "BAIRRO": "TESTE",
                    "CEP": "12345-678",
                    "CIDADE": "TESTE",
                    "ESTADO": "11",
                    "NATURALIDADE": null,
                    "TELEFONE": "21 1234-56789",
                    "CELULAR": null,
                    "PROFISSAO_ID": "996",
                    "EMAIL": "[email protected]",
                    "DATA_NASCIMENTO": "05\/01\/1980",
                    "DATA_CADASTRO": "2017-12-06 20:09:28",
                    "STATUS": "A",
                    "ORGAO_ID": "2",
                    "ORGAO_ESTADO_ID": "7",
                    "ORGAO_NUMERO": "102030",
                    "CODIGO_PLANO": "1",
                    "VALOR_PLANO": "86,40",
                    "METODO_PAGAMENTO": "CREDIT_CARD",
                    "ORGAO": "CRECI",
                    "PROFISSAO": "CORRETOR",
                    "VALOR_PLANO_ORIGINAL": "8640",
                    "UF_SIGLA": "MG",
                    "PROXIMA_FATURA": null,
                    "CODE": "1",
                    "PARCELAS": "1 parcela",
                    "AMOUNT": "8640",
                    "PLANO": ""
                }
    
    
            });
    Not Working

    Code:
     Ext.define('Myapp.view.TestesViewModel', {
                extend: 'Ext.app.ViewModel',
                alias: 'viewmodel.testes',
    
    
                  stores: {
                      corretores: {
                          autoLoad: true,
                          autoSync: true,
                          model: 'Myapp.model.cadastro.Teste',
                          proxy: {
                              type: 'ajax',
                              api: {
                                  read: 'data1.json'
                              },
                              reader: {
                                  type: 'json',
                                  rootProperty: 'testes'
                              }
                          }
                      }
                  }
                
    
                /*data: {
                    "CORRETOR_ID": "24",
                    "NOME": "WAGNER NOGUEIRA",
                    "CPF": "12345678901",
                    "RG": null,
                    "PASSAPORTE": null,
                    "ENDERECO": "RUA TESTE",
                    "NUMERO": "100",
                    "COMPLEMENTO": "SL 101",
                    "BAIRRO": "TESTE",
                    "CEP": "12345-678",
                    "CIDADE": "TESTE",
                    "ESTADO": "11",
                    "NATURALIDADE": null,
                    "TELEFONE": "21 1234-56789",
                    "CELULAR": null,
                    "PROFISSAO_ID": "996",
                    "EMAIL": "[email protected]",
                    "DATA_NASCIMENTO": "05\/01\/1980",
                    "DATA_CADASTRO": "2017-12-06 20:09:28",
                    "STATUS": "A",
                    "ORGAO_ID": "2",
                    "ORGAO_ESTADO_ID": "7",
                    "ORGAO_NUMERO": "102030",
                    "CODIGO_PLANO": "1",
                    "VALOR_PLANO": "86,40",
                    "METODO_PAGAMENTO": "CREDIT_CARD",
                    "ORGAO": "CRECI",
                    "PROFISSAO": "CORRETOR",
                    "VALOR_PLANO_ORIGINAL": "8640",
                    "UF_SIGLA": "MG",
                    "PROXIMA_FATURA": null,
                    "CODE": "1",
                    "PARCELAS": "1 parcela",
                    "AMOUNT": "8640",
                    "PLANO": ""
                }*/
    
    
            });
    What i need to do to fix this problem? i need to databinding in my form using ajax...

    Follow example in fiddle:
    https://fiddle.sencha.com/#view/editor&fiddle/2aor

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,257
    Answers
    759

    Default

    A store is a list of records, how are you writing the bindings when you're attaching the store?

    For example, binding to:

    Code:
    bind: '{EMAIL}',
    Doesn't make any sense if you have a store, because:
    a) It doesn't reference the store anywhere
    b) There is no top level EMAIL data.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3
    Sencha User
    Join Date
    Aug 2017
    Location
    Brazil
    Posts
    5

    Default

    Hi Evant,
    That i need to do to load databinding in this form: https://fiddle.sencha.com/#view/editor&fiddle/2aor, i fix this problem using links, but in sencha architect present this error:

    Error.jpg

    Sencha architect 4.2.2 extjs 6.5.1

Similar Threads

  1. Form problem, Databind values using ajax proxy
    By digifarma in forum Ext JS 6.x Q&A
    Replies: 1
    Last Post: 11 Dec 2017, 10:43 AM
  2. Ext.Ajax.request vs. proxy: { type : 'ajax'...
    By oldby in forum Ext: Discussion
    Replies: 3
    Last Post: 14 Dec 2015, 4:34 AM
  3. Replies: 1
    Last Post: 1 Sep 2012, 7:00 AM
  4. Replies: 3
    Last Post: 27 Jul 2012, 12:51 PM
  5. Ext.Ajax.request vs. proxy: { type : 'ajax'...
    By oldby in forum Ext: Discussion
    Replies: 1
    Last Post: 30 May 2011, 3:47 AM

Tags for this Thread

Posting Permissions

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