Results 1 to 4 of 4

Thread: Add another record in a dataStore after first load

  1. #1
    Sencha User
    Join Date
    Mar 2011
    Posts
    31

    Default Add another record in a dataStore after first load

    Hi everyone,

    i want to add a record in a dataStore.

    Code:
        var stoTicketsActionPublique = new Ext.data.Store({
            storeId: 'stoTicketsActionPublique',
            url: 'data/incidents/getActionsTicketSuivi.php',
            remoteSort: true,
            autoLoad: true,
            method: 'POST',
            baseParams: {
                numAppel:        numAppel,
                typeAction:        1
            },
            reader: 
                new Ext.data.JsonReader({
                    totalProperty: 'total',
                    root: 'ticket'
                },
                new Ext.data.Record.create([
                    {name: 'ComPublic'},
                    {name: 'DAction'},
                    {name: 'TypeAction'}
    
                    
                ])
            ),
    
        });
    This dataStore is load in a GridPanel.

    Code:
    var grdActionsTickets = new Ext.grid.GridPanel({
            id: 'grdActionsTickets',
            renderTo: document.getElementById('divcontentProblemeHtml' + numAppel),
            ds: stoTicketsActionPublique,
            title: 'Action sur votre ticket',
            iconCls: 'linkBreak',
            loadMask: {showMask: true, msg: 'Chargement en cours...'},
            width: 800,
            height: 500,
            sm: new Ext.grid.RowSelectionModel({ singleSelect: true }),
            cm: new Ext.grid.ColumnModel([
                {header: "Date de l'Action",        dataIndex: 'DAction',        width: 100,    sortable: true},
                {header: "Type de l'Action ",        dataIndex: 'TypeAction',    width: 148,    sortable: true},
                {header: 'Commentaire',                dataIndex: 'ComPublic',        width: 542,    sortable: true}
            ]),
            viewConfig: {
            //      Return CSS class to apply to rows depending upon data values
            getRowClass: function(record, index) {
                var c = record.get('TypeAction');
                if (c == "Mise \u00e0 jour") {
                    return 'expense-high';
                } else{
                    return 'expense-low';
                }
            }
        }
    });
    For add another record i use

    Code:
    var Person = Ext.data.Record.create([{
        name: 'ComPublic'
    }, {
        name: 'TypeAction'
    }]);
    stoTicketsActionPublique.add(new Person({
        ComPublic: 'Ned',
        TypeAction: 'Flanders'
    }));
    But this add is loading before the gridPanel store load, and he is overwritted by my dataStore.

  2. #2
    Sencha User fay's Avatar
    Join Date
    Apr 2007
    Location
    Ireland
    Posts
    1,750

    Default

    Add a load event handler to your store and then do your add:

    Code:
     
    stoTicketsActionPublique.on('load', function(store, records, options)
    {
    });

  3. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    31

    Default

    I make some try about this load, but it doesn't work.
    Can you explain explain me how to use it?

  4. #4
    Sencha User
    Join Date
    Mar 2011
    Posts
    31

    Default

    It's ok thanks !!

Similar Threads

  1. How to add blank record to datastore
    By hardcoremore in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 14 Jan 2009, 5:27 PM
  2. how can i have one dataStore with various number of record ?
    By hadikazemi in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 14 Feb 2008, 7:06 AM
  3. When it comes to inserting a record into dataStore ...
    By NTR in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 7 Oct 2007, 2:42 PM
  4. 1.1 How do you get the id of a record from a datastore?
    By John Sourcer in forum Ext 1.x: Help & Discussion
    Replies: 8
    Last Post: 20 Sep 2007, 4:50 AM
  5. How to add new record to DataStore?
    By jsakalos in forum Ext 1.x: Help & Discussion
    Replies: 5
    Last Post: 7 May 2007, 6:51 AM

Posting Permissions

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