1. #1
    Sencha User
    Join Date
    Apr 2007
    Posts
    172
    Vote Rating
    1
    medusadelft is on a distinguished road

      0  

    Default Grid to grid drag and drop: how to sync store?

    Grid to grid drag and drop: how to sync store?


    Hi,

    I've got two grids. I drag from grid 'one' to grid 'two'.
    In the 'beforedrop' event for grid 'two', I alter the data.records slightly (adding two fields with default values as these don't exist in grid 'one').
    Grid 'two' show the new dragged record. So drag and drop is working.

    However, I want to save this record to my database. So I added to the 'drop' event for grid 'two', code to save this record. Unfortunately, I've tried several commands, but none is working properly.
    Store is not synchronized (dirty property not updated or store doesn't contain new record, or grid show the just dropped record twice):
    PHP Code:
    // Shows twice in grid:
    drop: function(nodedatadropRecdropPosition) {
        
    this.store.add({
            
    members_iddata.records[0].get('id')
            ,
    teams_iddata.records[0].get('teams_id')
            ,
    fullnamedata.records[0].get('fullname')
            ,
    sortorderdata.records[0].get('sortorder')
            ,
    is_team_captain0
        
    });
        
    this.store.sync();
    }

    // Record saved to database, but store not synchronized, so updates to this record do nothing (no proxy update or change event is fired)
    drop: function(nodedatadropRecdropPosition) {
        var 
    member Ext.ModelManager.create({
            
    members_iddata.records[0].get('id')
            ,
    teams_iddata.records[0].get('teams_id')
            ,
    fullnamedata.records[0].get('fullname')
            ,
    sortorderdata.records[0].get('sortorder')
            ,
    is_team_captain0
            
    ,id0
            
    ,number_subteam''
        
    }, 'EX.model.Player');
        
    member.save();

        
    // this sync command does nothing!
        
    this.store.sync();

    My Model:
    PHP Code:
    Ext.define('EX.model.Player', { 
        
    extend'Ext.data.Model'
        
    ,fields: [
            {
    name'id'type'int'}    
            ,{
    name'teams_id'type'int'}
            ,{
    name'members_id'type'int'}
            ,{
    name'sortorder'type'int'}
            ,{
    name'fullname'type'string'}
            ,{
    name'number_subteam'type'string'}
            ,{
    name'is_team_captain'type'bool'}
        ] 

        ,
    proxy: {
            
    type'ajax'
            
    ,extraParams: {
                
    teams_id0
                
    ,players_id0
            
    }
            ,
    api: {
                
    create'phpscripts/updatePlayers.json.php' 
                
    ,read'phpscripts/players.json.php'
                
    ,update'phpscripts/updatePlayers.json.php' 
                
    ,destroy'phpscripts/deletePlayers.json.php' 
            
    }
            ,
    reader: {
                
    type'json'
                
    ,root'response'
            
    }
        }
    }); 
    My Store:
    PHP Code:
    Ext.define('EX.store.Players', { 
        
    extend'Ext.data.Store'
        
    model'EX.model.Player',
        
    autoLoadtrue
    }); 
    I still have the problem that I can't put these listeners functions in my controller because I don't know how to 'catch' the event in the control-function.

    Any help is appreciated!

    Thanks,
    Maurice.

    BTW: accessing Ext.ModelManager.getModel('string/id') is not working if I put in the id (already removed from my model as it didn't work) or string 'Player' is not working. 'EX.model.Player' seems to work. It looks like only the 'name' of the model is used here. Is this correct and should I file bug-report?

  2. #2
    Sencha User
    Join Date
    Mar 2010
    Posts
    456
    Vote Rating
    0
    abcdef is an unknown quantity at this point

      0  

    Default


    Were you able to figure this out?

  3. #3
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    2,731
    Vote Rating
    104
    mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all

      0  

    Default


    You should first create a new model, then add that to the store of the 2nd grid. This should issue a 'create' request as the new model is added to the new store. Is this what you'd like?

  4. #4
    Sencha User
    Join Date
    Mar 2010
    Posts
    456
    Vote Rating
    0
    abcdef is an unknown quantity at this point

      0  

    Default


    So with regard to my post at:

    http://www.sencha.com/forum/showthre...ropped-records

    , when the target grid registers a drop event, I need to create a new record on the target grid's store? When I call store.sync() on the source store (the grid that the record was dragged from), it sends out a delete request through REST - which is fine.

    On the target grid though, I set a property that I need to change, and then set the record to dirty (with setDirty()). At this point, I am expecting the target grid's store to sync (on calling .sync()), because the record is now phantom, right? .sync() uses internally getNewRecords(), getModifiedRecords(), and getRemovedRecords() - and only getRemovedRecords seems to return something, the others seem to return an empty array all the time? So anyway, .sync() doesn't do anything.

    How do I solve this issue?

    Please help!

    Thanks a ton for your time!

  5. #5
    Sencha User
    Join Date
    Jan 2008
    Location
    Nice, France
    Posts
    43
    Vote Rating
    0
    manube is on a distinguished road

      0  

    Default


    Hello,

    I've got the same issue.
    Did you resolve it?

    Thanks a lot

  6. #6
    Sencha User
    Join Date
    Sep 2010
    Posts
    5
    Vote Rating
    0
    bazis is on a distinguished road

      0  

    Default


    I add a listener to my grid for workaround:
    Code:
    viewConfig: {
          plugins: {
               ptype: 'gridviewdragdrop',
               dragGroup: 'secondGridDDGroup',
               dropGroup: 'firstGridDDGroup'
          },
          listeners: {
               beforedrop: function(node, data, dropRec, dropPosition) {
                      Ext.Array.each(data.records, function(rec) {
                            rec.setDirty();
                      });
               }
          }
    },

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi