Results 1 to 2 of 2

Thread: GroupingStore with Dynamic Data from Ajax Request

  1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    8
    Vote Rating
    0
      0  

    Default GroupingStore with Dynamic Data from Ajax Request

    Hello everybody, I'm a newbie of extjs and I have a real big problem.....I hope you could help me.

    What I'm tring to do is to populate a GroupingStore with an array that change under an ajax request.....here is what I do:

    First of all I make a query in PHP like this

    Code:
    <?php  
     
    include("common_php_header.php");
     
    //$chi_sta_giocando = $_SESSION['userid'];
    
    $idCommessa = $_POST['commessaSelezionata'];
    
    $json_array = array(array());
    
    $query_articoli =  "SELECT      tb_descrizione_ordini.id                                AS id_articoli,
                                    tb_descrizione_ordini.descrizione                       AS descrizione_articoli,
                                    tb_descrizione_ordini.rimosso                           AS rimosso_articoli,
                                    tb_descrizione_ordini.quant                             AS quant_articoli,
                                    tb_descrizione_ordini.prezzo_unit                       AS prezzo_unit_articoli,
                                    tb_descrizione_ordini.id_misura_quant                   AS id_misura_quant_articoli,
                                    tb_descrizione_ordini.posizione                         AS posizione_articoli,
                                    tb_lista_ordini.id                                      AS id_ordine,
                                    tb_lista_ordini.id_offerta                              AS id_offerta_ordine,
                                    tb_lista_ordini.num_ord_cliente                         AS num_ord_cliente_ordine,
                                    tb_lista_ordini.importo_ordine                          AS importo_ordine_ordine
                        FROM        tb_descrizione_ordini, tb_lista_ordini
                        WHERE       tb_descrizione_ordini.id_ordine = tb_lista_ordini.id
                                    AND tb_lista_ordini.id_commessa = '$idCommessa'";
                     
    $result_articoli  = mysql_query($query_articoli) or die("<b>A fatal MySQL error  occured</b>.\n<br />Query: " . $query_articoli . "<br  />\nError: (" . mysql_errno() . ") " . mysql_error());
    
    
    $i = 0;
    
    while($row_articoli = mysql_fetch_assoc($result_articoli))
    {
        $json_array[$i] = $row_articoli;
        $i++;
    }
    
    echo json_encode($json_array);
    
    ?>
    This request is in a function in the js file, that is fired when I chose a record in a combobox (I pass the commessaSelezionata parameter)

    So my idea was to make a function like this:

    Code:
    function aggiornaListaArticoliSx(idCommessa){
        gridArticoliSx.el.mask('Attendere...', 'x-mask-loading');
        Ext.Ajax.request({
            url: 's_find_descrizione_ordini_mt.php',
            params: {commessaSelezionata:idCommessa},
            method: 'POST',
            success: function(result) {
                if( (result.responseText == 'Oggetto target ignoto.') ||
                    (result.responseText == 'Connessione non riuscita') ||
                    (result.responseText == 'Database non trovato') )
                    {
                    finestraAvviso(result.responseText,'Errore.');
                    }
                else{
    //                listaArticoliSx.removeAll();
    //                listaArticoliSx.loadData(Ext.decode(result.responseText));
                      store_dati.removeAll();
                      store_dati.loadData(Ext.decode(result.responseText));
                    }
                },
            failure: function() {
                finestraAvviso('Connessione al server fallita !','Errore.');
                }
            });
        }
    and after that using a

    store_dati.on('load',function(){
    //listaArticoliSx.commitChanges();
    listaArticoliSx.reload();
    //listaArticoliSx.loadData(store_dati);
    gridArticoliSx.el.unmask();
    });
    to load the store_dati that will be used to "reload" the grouping store listaArticoliSx

    var listaArticoliSx = new Ext.data.GroupingStore({
    //root: 'data_root',
    //fields: ['id_articoli','descrizione_articoli', 'rimosso_articoli', 'quant_articoli', 'prezzo_unit_articoli', 'id_misura_quant_articoli', 'posizione_articoli', 'id_ordine', 'id_offerta_ordine', 'num_ord_cliente_ordine', 'importo_ordine_ordine'],
    reader: lettore_campi,
    //url:'s_find_descrizione_ordini_mt.php',
    //autoload:false,
    data: store_dati,
    sortInfo:{field: 'descrizione_articoli', direction: "ASC"},
    groupField:'id_ordine',
    autoDestroy: false
    });
    Unfortunately I've this problem

    this.proxy is undefined
    that I think is related to the reload method.....




    Could someone help me??

    p.s. sorry for my english and for some comments in the code, I've tried different solutions.....remember I'm a newbie XD

    p.p.s I've edited a stupid command ------- //listaArticoliSx.loadData(store_dati); sorry

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Vote Rating
    394
      0  

    Default

    Calling reload() on a store will causes it to try to retrieve new data via its proxy. In most cases the proxy is an HttpProxy and this will attempt to load the data from the server via an Ajax request. Your store does not have a proxy or a url configured so this attempt to load data via the proxy will fail.

Posting Permissions

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