Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Using ui.sortable to save data
27/06/2010
19:52
Avatar
Reg
Calgary, Canada
Member
Members
Forum Posts: 92
Member Since:
06/06/2008
sp_UserOfflineSmall Offline

I am just converting to ver 3.7 and want to use ui.sortable instead of tableDnD; what I cannot figure out is how to send the change to the server when a row has been dropped. What i have from the jQuery site (and the jGrid examples) is the following:

      gridComplete : function () {
          $("#tbloperatorgroups").jqGrid('sortableRows');
         }

....

    $( "#tbloperatorgroups" ).bind( "sortupdate", function(event, ui) {
            var posturl = updating url ending with: &PK='+row.id; 
            var neworder = $.sortable.serialize();
            $.post( posturl, neworder, function(message,status) {
                if(status != 'success') {
                    alert(message);
                  }
              })
          }
      ) ;

This code snippet has been copied from the tableDnD approach and may no longer be the way to do things. The error I get is that "row" (in the posturl) is unknown. 

How do I include the ID of the moved row -- or do I not need to anymore? The documentation isn't very helpful on this.

Thanks

Reg

30/06/2010
16:56
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello Reg,

The way that you use this is not correct. The sortable rows method should not be called in grid Complete event, but after the creation of the grid.

Go into the demo

New in version 3.6 => Sortable Row example

There is a code which will give you a idea.

Also you can set the update event in the same method

jQuery("#sortrows").jqGrid('sortableRows', {

       update: function (event, ui) {

       ....

      }

});

Hope this helps

Best Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

30/06/2010
20:36
Avatar
Reg
Calgary, Canada
Member
Members
Forum Posts: 92
Member Since:
06/06/2008
sp_UserOfflineSmall Offline

Hi Tony,

Thanks for the re-direction. I have made the change to how I create the grid and the related calls, but am still missing something in my understanding. My code now looks like this:

    $("#tbloperatorgroups").jqGrid('sortableRows', {
        update: function(event, ui) {
        var posturl = 'wc.dll?PSProcess~AjaxReseq~&Data=OperatorGroups&sk=2YZ0HTYFD06840&sh=104'; 
        var neworder = $("#tbloperatorgroups").sortable("serialize");
        $.post( posturl, neworder, function(message,status) {
            if(status != 'success') {
                alert(message);
              }
          })
        }
      })

but neworder contains &undefined = undefined

If I try to put an underscore in the name of the id attribute, the way the jQuery docs suggest, I get the same error.

        var neworder = $("#tbloperatorgroups").sortable("serialize",[id='row_id']);

So I am still doing something wrong.

I still need some help, please.

Thanks

Reg

06/07/2010
11:41
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello Reg,

Instead of serialize I recommend you to use getDataIDs method to obtain the ids of the grid and post them to the server.

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

06/07/2010
17:20
Avatar
Reg
Calgary, Canada
Member
Members
Forum Posts: 92
Member Since:
06/06/2008
sp_UserOfflineSmall Offline

Hello Tony,

Thanks for the tip.

I now have the following:

    $("#tbloperatorgroups").jqGrid('sortableRows', {
        update: function(event, ui) {
        var posturl = 'wc.dll?PSProcess~AjaxReseq~&Data=OperatorGroups&sk=2Z50G0BMF14352&sh=24'; 
        var neworder = $("#tbloperatorgroups").jqGrid("getDataIDs");
        $.post( posturl, neworder, function(message,status) {
            if(status != 'success') {
                alert(message);
              }
          })
        }
      })

and the grid visually sorts and posts to the server, but neworder contains an array of $undefined=undefined (one for each row inthe grid)

If I change the "var neworder" line to

var neworder = $("#tbloperatorgroups").getDataIDs(); 

I get the same result.

When I create the data, I include a < row id > element

What am I doing wrong?

Thanks,

Reg

12/07/2010
00:35
Avatar
uyuni
New Member
Members
Forum Posts: 1
Member Since:
12/07/2010
sp_UserOfflineSmall Offline

correct is:

        var neworder = $("#tbloperatorgroups").jqGrid("getDataIDs").join(',');

Emilio

12/07/2010
17:39
Avatar
Reg
Calgary, Canada
Member
Members
Forum Posts: 92
Member Since:
06/06/2008
sp_UserOfflineSmall Offline

Thank you Emilio, I have made the change you suggest and it now works just the way I want it to.

Thanks again,

Reg

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
52 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information