2010-07-07 79 views

回答

1

我發現Ext.GridPanel行排序通過在博客中拖放工作示例http://hamisageek.blogspot.com/2009/02/extjs-tip-sortable-grid-rows-via-drag.html 它對我來說工作得很好。在這裏我的js代碼:

app.grid = new Ext.grid.GridPanel({ 
    store: app.store, 
    sm: new Ext.grid.RowSelectionModel({singleSelect:false}), 
    cm: new Ext.grid.ColumnModel({ 
     columns: app.colmodel 
    }), 
    ddGroup: 'dd', 
    enableDragDrop: true, 
    listeners: { 
     "render": { 
      scope: this, 
      fn: function(grid) { 
      // Enable sorting Rows via Drag & Drop 
      // this drop target listens for a row drop 
      // and handles rearranging the rows 

        var ddrow = new Ext.dd.DropTarget(grid.container, { 
         ddGroup : 'dd', 
         copy:false, 
         notifyDrop : function(dd, e, data){ 

          var ds = grid.store; 

          // NOTE: 
          // you may need to make an ajax call 
          // here 
          // to send the new order 
          // and then reload the store 


          // alternatively, you can handle the 
          // changes 
          // in the order of the row as 
          // demonstrated below 

          // *************************************** 

          var sm = grid.getSelectionModel(); 
          var rows = sm.getSelections(); 
          if(dd.getDragData(e)) { 
           var cindex=dd.getDragData(e).rowIndex; 
           if(typeof(cindex) != "undefined") { 
            for(i = 0; i < rows.length; i++) { 
            ds.remove(ds.getById(rows[i].id)); 
            } 
            ds.insert(cindex,data.selections); 
            sm.clearSelections(); 
           } 
          } 

          // ************************************ 
          } 
         }) 

         // load the grid store 
         // after the grid has been rendered 
        this.store.load(); 
        } 
       } 
    } 
}); 
+0

也許[這]( http://www.sencha.com/forum/showthread.php?21913-SOLVED-Grid-Drag-and-Drop-reorder-rows&p=560975&viewfull=1#post560975)extjs論壇主題將對某人有用。 Guys會爲dragndroppable-grid-rows或類似的東西創建一個插件。 – 2011-04-22 07:51:36

0

如果通過側

new Ext.Panel(
{ 
    layout: "hbox", 
    anchor: '100% 100%', 
    layoutConfig: 
    { 
     align: 'stretch', 
     pack: 'start' 
    }, 
    items: [GridPanel1, GridPanel2, GridPanel3 
}) 

然後用3電網側有橫向盒佈局必須JUSE電網厄爾尼諾,而不是容器

var ddrow = new Ext.dd.DropTarget(grid.getEl(), { ....