1. #1
    Sencha User
    Join Date
    Mar 2010
    Posts
    492
    Vote Rating
    1
    Answers
    12
    abcdef is on a distinguished road

      0  

    Default Unanswered: Grid Drag & Drop, and Getting dropped records

    Unanswered: Grid Drag & Drop, and Getting dropped records


    I have implemented multiple grids tied to respective stores and models. These models differ by only 1 property. I need to be able to drag and drop records amongst the grids. So when I do that, the store of the grid that I drop records into show updated total no. of records correctly, but when I try to use geNewRecords() on the dropped grid's store, I always get 0 no. of records.

    Question: Is this expected? How do I then get the new records, and save (and sync to backend) on the store attached to the grid that the record was dropped into?

    Edit: Also, I manually set the record to dirty. The source store returns the correct no. of removed records, but the target store does not return new or modified records. I am not using an editable grid. I am manually setting the value of the property that needs to be changed. On store.sync(), the source store sends a request to server, but the target store does not - I am guessing that is because getModified.., getNew.., and getRemoved.., are all empty arrays for the target store.

    Please help! This is a blocking issue for me at the moment.

    Thank you.

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,052
    Vote Rating
    215
    Answers
    484
    slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of

      0  

    Default


    Are you using the plugin type: gridviewdragdrop for your grids?

  3. #3
    Sencha User
    Join Date
    Mar 2010
    Posts
    492
    Vote Rating
    1
    Answers
    12
    abcdef is on a distinguished road

      0  

    Default


    Quote Originally Posted by slemmon View Post
    Are you using the plugin type: gridviewdragdrop for your grids?
    Yes.

  4. #4
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,052
    Vote Rating
    215
    Answers
    484
    slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of

      0  

    Default


    I modified the grid-to-grid example to add a toolbar in the second grid and added a couple of buttons to it.
    The first button gets the new records using the store's getNewRecords method and logs it to the console. If I add a record and then click the getNewRecords button it finds the record that I added. It's a phantom record and is dirty = false.

    The second button marks all new records as dirty and refreshes the grid's view.

    I can move a record and click the getNewRecords button and it shows the record or records as new and not dirty. I set them to dirty. I then check to see if I get the same records a second time and I do and they're dirty now. But, both times it's finding the records.

    I haven't tried syncing them anywhere via a proxy and the sync method, but it seems like it would since the records are founds as new (and dirty after marking them as such).

    If you set something like that up in your project the getNewRecords is finding 0 records in the destination grid after the move, though, correct?

  5. #5
    Sencha User
    Join Date
    Mar 2010
    Posts
    492
    Vote Rating
    1
    Answers
    12
    abcdef is on a distinguished road

      0  

    Default


    Thank you very much for your time.

    So I tried giving 'id's to all the data for the grid drag and drop example from the website...So modified bits of code from the original example:

    Code:
    Ext.define('DataObject', {
        extend: 'Ext.data.Model',
        fields: ['id', 'name', 'column1', 'column2']
    });
    
    var myData = [
            { id: 9588536, name : "Rec 0", column1 : "0", column2 : "0" },
            { id: 10588536, name : "Rec 1", column1 : "1", column2 : "1" },
            { id: 29588536, name : "Rec 2", column1 : "2", column2 : "2" }
        ];
    
    var columns = [
            {text: "Id", flex: 1, sortable: true, dataIndex: 'id'},
            {text: "Record Name", flex: 1, sortable: true, dataIndex: 'name'},
            {text: "column1", width: 70, sortable: true, dataIndex: 'column1'},
            {text: "column2", width: 70, sortable: true, dataIndex: 'column2'}
        ];
    So in data, when I set 'id' to 0, 1, and 2 - .getNewRecords() returns me the phantom records on drop. But when I change it to large numbers as shown above, it does not.

    Is that expected? What am I missing here?

    Thanks again!

  6. #6
    Sencha User
    Join Date
    Mar 2010
    Posts
    492
    Vote Rating
    1
    Answers
    12
    abcdef is on a distinguished road

      0  

    Default


    Any ideas on this one anyone?

  7. #7
    Sencha User
    Join Date
    Mar 2010
    Posts
    492
    Vote Rating
    1
    Answers
    12
    abcdef is on a distinguished road

      0  

    Default


    So how is this situation ideally supposed to be handled:

    1. I have data coming separately to 3 grids from their respective stores. They are all the same kind of data - with one distinguishing property (say 'distName').

    2. When I drag a record from 1 grid to the other, I need to set the dragged record's 'distName' property to match that of the grid that it was dragged into.

    3. Then I need to sync these stores back to the server.

    Also, getNewRecords() doc says:

    Code:
    Returns all Model instances that are either currently a phantom (e.g. have no id), or have an ID but have not yet been saved on this Store (this happens when adding a non-phantom record from another Store into this one)
    So even if my record has an id field, shouldn't getNewRecords() be returning me the record that was dragged into the store from the original grid's store because the record at that point has not been saved to the new grid's store?

    The behavior is getting confusing, and any clarity on this matter would be highly appreciated!

  8. #8
    Sencha User
    Join Date
    Mar 2011
    Posts
    10
    Vote Rating
    0
    zfcflower is on a distinguished road

      0  

    Default


    You need to set before the drag model properties phantom = true, I am alsodepressed too, want to help you!

Thread Participants: 2

Tags for this Thread