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_Related Related Topics sp_TopicIcon
Subgrids not working with scroll: 1
30/09/2011
12:06
Avatar
Omnimike
Australia
New Member
Members
Forum Posts: 1
Member Since:
30/09/2011
sp_UserOfflineSmall Offline

Hi everyone,

I've encountered an issue when using subgrids and virtual scrolling where some rows will not expand when clicked, while others work fine.

After doing some digging I discovered that the reason some of them are not opening is because the event which opens them is being fired twice (the first one opening it, the second one closing it straight away). It seems that the click event to expand the subgrid is being bound properly the first time, but because of how virtual scrolling is implemented when additional rows are added to the grid the click events for the subgrids is being bound again to all the rows in the grid (including the ones already in there), so the function to expand a subgrid is being bound twice.

I get the bug with the following config. The url and colModel are different when I actually test it (I can't post the real code here).

$('#grid').jqGrid({
url: 'search.php',
colModel: [{name: 'col1', label: 'Column 1'}],
cmTemplate: {width: 100},
jsonReader: {repeatitems: false},
datatype: 'json',
height: 400,
mtype: 'POST',
rowNum: 20,
scroll: 1,
subGrid: true
subGridRowExpanded: function(subgridId, rowId) {
$('#'+subgridId).append($('<p>Some text</p> '));
}
});

With this config I scroll down a litle bit (until the grid loads the next page) and then try to expand one of the rows which was already in the grid, which now does nothing.

If there's something I'm doing wrong then I'd be happy to hear it. At the moment I'm still searching for a work around.

Edit: My first attempt at solving the issue was the edit the grid code to unbind the click event before it binds it a second time. I edited the code in 'addSubGrid' from:

$(ts.rows[i].cells[pos]).bind('click', function(e) {

to:

$(ts.rows[i].cells[pos]).unbind('click.jqGrid');
$(ts.rows[i].cells[pos]).bind('click.jqGrid', function(e) {

Basically I added the click event to the jqGrid namespace and removed all the click events in that namespace prior to adding them (thereby stopping the event from being bound twice).

As far as I can tell jquery event namespaces aren't used in the grid code, so this shouldn't conflict with existing code. In the future if all the events were namespaced this might cause issues if the grid binds other functions to the click event of the row, so it's not an ideal solution.

Alternatives to this include storing a reference to the function so it can be unbound latter or (perhaps the better solution) ensure that addsubgrid doesn't set up the subgrid twice on a single row in the first place. I haven't thought of a workaround which doesn't involve changing the grid code somehow.

Thanks,

Michael.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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