Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Drag and grop to reorder grid

  1. #1
    Ext User
    Join Date
    Aug 2009
    Posts
    23

    Default Drag and grop to reorder grid

    Hi,
    anyone knows how to make a grid to reorder on drag and drop?
    I also need myData array to be sent to the server on this action.

    Thanks in advance,
    titzu

    PHP Code:
    var myData = [
            [
    '3m Co',71.72,0.02,0.03,'9/1 12:00am'],
            [
    'Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
            [
    'Altria Group Inc',83.81,0.28,0.34,'9/1 12:00am'],
            [
    'American Express Company',52.55,0.01,0.02,'9/1 12:00am'],
            [
    'American International Group, Inc.',64.13,0.31,0.49,'9/1 12:00am']
        ];

        
    // create the data store
        
    var store = new Ext.data.ArrayStore({
            
    fields: [
               {
    name'company'},
               {
    name'price'type'float'}
            ]
        });

        
    // manually load local data
        
    store.loadData(myData);

        
    // create the Grid
        
    var grid = new Ext.grid.GridPanel({
            
    storestore,
            
    columns: [
                {
    id:'company',header'Company'width70sortablefalsedataIndex'company'},
                {
    header'Price'width75sortablefalserenderer'usMoney'dataIndex'price'},
            ],
            
    stripeRowstrue,
            
    height200,
            
    width400,
            
    enableDragDroptrue,
            
    enableColumnMovetrue,
            
    title'Guestions',
            
    // config options for stateful behavior
            
    statefultrue,
            
    stateId'grid'        
        
    }); 

  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    Itackled this in Chapter 11 of Ext JS in Action.

    Below is the source to the solution to this problem.
    These links are not static and will probably change.

    Here is a single dnd implementation: http://extjsinaction.com/examples/ch...grid_self.html
    and double dnd : http://extjsinaction.com/examples/ch...ith_grids.html

    Inject the ajax request before you remove nodes.

    I'm actually working on the code to do this now.

  3. #3
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    I've just updated them to include ajax

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    those links have been snipped. they actually contain those dots...

  5. #5
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    Ugh! thanks nige. I've updated that post. I'm an *****.

  6. #6
    Ext User
    Join Date
    Aug 2009
    Posts
    23

    Default

    Thanks a lot man

  7. #7
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    FYI, http://extjsinaction.com/examples/ch...grid_self.html inserts the new node at the wrong place.

    Seems like its using the nunber as a zero-based index when inserting at the new position. Try it.

  8. #8
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    nice catch. I must have just introduced that bug with some of the index changes i've made today. I'm on to fix that now. will post asap.

  9. #9
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    OK, fixed and split into two examples - with and without ajax:


    Ajax: http://extjsinaction.com/examples/ch...with_ajax.html

    without ajax
    http://extjsinaction.com/examples/ch...grid_self.html


    Nige, as always, thanks so much for your valued input.

  10. #10
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Those links don't work.

Page 1 of 2 12 LastLast

Posting Permissions

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