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
Select first row of a grid
14/10/2009
08:08
Avatar
glemarie
France
Member
Members
Forum Posts: 66
Member Since:
19/12/2008
sp_UserOfflineSmall Offline

Hello,

I'd like to select the first row of a grid on loadComplete. I don't know the rowid.

How can I do this ? Is there a way to get the rowid of the first row and then use setSelection ?

Thanks

14/10/2009
12:40
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

I do not think that loadComplete is a good choice. Better you can  use gridComplete and then

gridComplete: function () {

var firstid = $("tr:first","#mygrid").attr("id");

$("#mygrid").setSelection(firstid);

}

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.

15/10/2009
02:15
Avatar
glemarie
France
Member
Members
Forum Posts: 66
Member Since:
19/12/2008
sp_UserOfflineSmall Offline

Thanks a lot : it was so simple...

23/02/2010
11:00
Avatar
glemarie
France
Member
Members
Forum Posts: 66
Member Since:
19/12/2008
sp_UserOfflineSmall Offline

Hello,

It seems that this solution doesn't work anymore. I upgraded each version up to 3.6.4, but I didn't notice when this occured. The returned id is always null (the row is not found).

I'm not a jQuery expert... I tried these :

$("tr:first", "tbody:first", "#mygrid").attr('id');

$("#mygrid tbody:first tr:first").attr('id');

$("#mygrid > tbody:first > tr:first").attr('id');

But none worked.

Any idea ?

Regards.

23/02/2010
11:56
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

in firefox do

var test1  = $("tr:first","#mygrid")

console.log(test1);

and so on -

see what is happen in the console tab

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.

23/02/2010
12:30
Avatar
glemarie
France
Member
Members
Forum Posts: 66
Member Since:
19/12/2008
sp_UserOfflineSmall Offline

I tried with the tr selector but the result shows nothing :

With TR selectorImage Enlarger

But it seems ok with the tbody selector $("tbody:first","#mygrid") :

With TBODY selectorImage Enlarger

But I don't undestand why I have this result in the first case ?!

Thanks…

23/02/2010
12:42
Avatar
glemarie
France
Member
Members
Forum Posts: 66
Member Since:
19/12/2008
sp_UserOfflineSmall Offline

I tried something else : I added a custuml button on my grid that calls your script :

console.log($("tr:first","#mygrid"))

In this case, the result is OK in the console !

Is it possible that when the gridComplete is fired, the rows are not in the table yet ??

I tried with :

  • jqGrid 3.6.3 / 3.6.4 : same problem
  • jQuery 1.3.2 / 1.4.1 : same problem
23/02/2010
15:18
Avatar
glemarie
France
Member
Members
Forum Posts: 66
Member Since:
19/12/2008
sp_UserOfflineSmall Offline

Sorry, forget the point, I have a stange side effect whith my own javascript... I had a condition in order to make the selection of the first row only on the page load (not on grid reload), but when I remove this condition, everything works fine...

Strange, but I don't have many time to investigate... So it's okay like that.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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