Results 1 to 5 of 5

Thread: keep single column values during gridrow drag-drop

  1. #1

    Default keep single column values during gridrow drag-drop

    I'm doing a drag-drop on my grid rows, which correctly moves the rows and places them, with all the row values into the newly selected row. The problem I'm facing is that I want to maintain one of the columns so that the values of that column always stay the same despite the row changing. Is there a way to skip the replacement of values for one column.

    PHP Code:
    var ddrow = new Ext.dd.DropTarget(grid, {
                    
    ddGroup 'testDDGroup',
                    
    copy:false,
                    
    notifyDrop : function(ddedata){            
                        var 
    sm=selModel;
                var 
    rows=sm.getSelections();
                        var 
    cindex=dd.getDragData(e).rowIndex;

                        if (
    typeof cindex != "undefined") {
                            for (
    0rows.lengthi++) {            
                                
    rowData=store.getById(rows[i].id);                            
                                if(!
    this.copy) {
                                    
    store.remove(store.getById(rows[i].id));
                                    
    store.insert(cindex,rowData);
                                }
                            }
                            
    sm.selectRecords(rows);
                        } 
                    }
         }); 

  2. #2
    Ext User para's Avatar
    Join Date
    Apr 2007
    Location
    Redmond, WA
    Posts
    918

    Default

    I don't think so. That kinda goes against the way the grid works.
    You could always just set it yourself.
    It may be an extra bit of code, but i think its the only way.

    There may be a more efficient way of doing it, but this type of thing would work...
    Code:
    var saveValues = {};
    for(var i=0; i<store.getCount(); i++) {
      saveValues[i] = store.getAt(i).get('valueDataIndex');
    }
    
    //complete the move
    
    store.suspendEvents();
    for(var i=0; i<store.getCount(); i++) {
      store.getAt(i).set('valueDataIndex', saveValues[i]);
    }
    store.resumeEvents();

  3. #3

    Default

    I would think there would be a fair amount of use for this. Such as when someone has a numbered grid with a column that includes row numbers. They drag-drop the grid rows but want to make sure the row numbers stay the same....in my case it is a ranking system.

    I guess it wouldn't be that much work to do another for loop or custom update for the column after the drag drop rendering had happened. I just wondered if anyone else had faced this problem and what their solution had been.

  4. #4

    Default

    I found a way that works for me. I don't know if it is the best solution but it might help others. I simply changed the data store value for each position in the column, after I did my drag-drop.

    PHP Code:
    .....
    sm.selectRecords(rows);
    var 
    rowCount datastore.reader.jsonData.RowsInGrid.length;
    var 
    jCount 0;
    for (
    j=rowCountj0j--){
                var 
    columnRecord datastore.getAt(jCount);
                var 
    newValue j;
                
    columnRecord.set('columnMappedName'newValue);
                
    jCount++;
    }
    .... 

  5. #5

    Default

    Oops Para, I see you did something almost the same in your post, I hadn't seen your example code in the post. Thanks for the help and hopefully it helps someone else.

Posting Permissions

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