Forum

July 12th, 2025
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
jqGrid + tableDnD selected class for row editing removed on mouseclick
15/01/2009
15:47
Avatar
Renso
PA
Member
Members
Forum Posts: 118
Member Since:
11/09/2008
sp_UserOfflineSmall Offline

I am using the tableDnD with jqGrid. AWESOME! So when I click on the row to move the item, it works fine with no issues.

Once you move your row, I make an ajax call on the tableDnD's onDrop handle. So when the data has been updated by the server I want to reload the grid (which works just fine) so that the sort order (which is also a colModel column the user can see) can be refreshed on the screen. This works great too. Bu now this is where I have the issue. How do I edit the record, that is, your jqGrid adds the "selected" class to the row so that when I click on the jqGrid footer's "edit this record" button it knows what record you selected. I tried to keep a reference with a variable to the row that was clicked on, but even though it successfully adds the "selected" class back to the clicked row after the grid has reloaded, I can see this in Firebug, it just adds it temporarily and then something else removes it again after just a split second, I am not sure what is removing it. I don't know if anyone else has this issue, and ideas. See my code example below:

item = my grid variable:

$(item).jqGrid({

...

        gridComplete: function() {
            $('tr.jqgrow', item).find('td:first').addClass('dragHandle');
            $('tr.jqgrow').hover(function() {
                $(this.cells[0]).addClass('showDragHandle');
            }, function() {
                $(this.cells[0]).removeClass('showDragHandle');
            });       
            $(item).tableDnDUpdate();
        },

...

})   //end of jqGrid definition

.tableDnD({
        onDrop: function(table, row) {
            $.ajax({
                data: $.tableDnD.serialize(),
                url: $('#ajaxUpdateLookupSortOrderUrl').val() + '/?lookup=' + $('#LookupListWrapper #LookupListSearchWrapper #Lookups').val(),
                type: "POST",
                success: function(data, result) {
                    //Reload so that the SortOrder column is refreshed from the DB with the new Sort Order
                    $(item).trigger('reloadGrid');
                    $(item).find('tr#'+$(row).attr('id')).addClass('selected');//trying to add the class back so that I can click on edit button
                }
            })
        }
    })
    ;

19/01/2009
11:38
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

The most common problem here that you should understand is this: (if I understand right)

$(item).trigger('reloadGrid');

After this you should call the expression

$(item).find('tr#'+$(row).attr('id')).addClass('selected');

WITH DELAY.

Use setTimeout for this purpose.

Regards

Tony

P.S. I suggest you to use setSelection for the experssion in blue.

or if this is not possible you should call setGridParam({selrow:'the_id_here'}) after the expression

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.

20/01/2009
09:29
Avatar
Renso
PA
Member
Members
Forum Posts: 118
Member Since:
11/09/2008
sp_UserOfflineSmall Offline

Thank you for your reply Tony.

Since the tableDnD passes in the row parm I was able to use the setSelection after a 200 milisecond delay:

$(item).trigger('reloadGrid');
                    setTimeout(function() { $(item).setSelection($(row).attr('id')); }, 200);

BTW, 200 miliseconds seems to be the minimum, if I go below this it starts to get unpredictable for larger lists. For example if you have a list of countries 100 is too little. For a list of 10 or so, 50 miliseconds is more than enough, so to be on the safe side and since my list of countries is the biggest I opted for 200ms. Please note that I use the same jqGrid for all my lookups.

23/06/2012
02:52
Avatar
sProcurement
Member
Members
Forum Posts: 3
Member Since:
23/06/2012
sp_UserOfflineSmall Offline

I am trying to use jqgrid treeview with table DND plugin to make tree nodes/leafs ( multiple rows) drag and drop between two grids.  I tried to use the code shown here. but it is not working for me. I am very new to jquery world. Please let me know if it is possible ? and will appreciate sharing some example code

thanks

23/06/2012
02:53
Avatar
sProcurement
Member
Members
Forum Posts: 3
Member Since:
23/06/2012
sp_UserOfflineSmall Offline

I forgot to mention that I am using local data

Forum Timezone: Europe/Sofia

Most Users Ever Online: 994

Currently Online:
16 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