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
setSelection does not select after reloadGrid (potential bug)
27/03/2010
03:38
Avatar
phamtranquocviet
Member
Members
Forum Posts: 22
Member Since:
06/02/2010
sp_UserOfflineSmall Offline

Hi,

setSelection does not select the row, whose id is 2, right after a reloadGrid.

        $("#training").setGridParam({url: 'index.php?func=trainingmgr&aAction=refreshData'});
        $("#training").trigger("reloadGrid");
        $("#training").jqGrid('setSelection', "2");

setSelection can select the row, whose id is 2, when you take this line out: $("#training").trigger("reloadGrid");

Anybody experience same issue?

Thanks

31/03/2010
19:05
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Sorry no time to explain, but try this:

        $("#training").setGridParam({url: 'index.php?func=trainingmgr&aAction=refreshData'});
        $("#training").trigger("reloadGrid");

setTimeout(function(){
        $("#training").jqGrid('setSelection', "2″);

}, 500);

It will be good if you explain why we should do it this way.

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.

01/04/2010
16:10
Avatar
unknown
Member
Members
Forum Posts: 9
Member Since:
01/04/2010
sp_UserOfflineSmall Offline

Hi,

I have the same problem in funktions like gridComplete and loadComplete. I do the following:

            setTimeout(function(){
              jQuery('#grid_orders').jqGrid('setSelection','1');
            },500);

and I test this:

              jQuery('#grid_orders').jqGrid('setSelection','1');

And no row is selected 🙁

Oh I always use the last version of JQGrid with JQuery in your download-zip

01/04/2010
16:23
Avatar
unknown
Member
Members
Forum Posts: 9
Member Since:
01/04/2010
sp_UserOfflineSmall Offline

So have my workaround:

$('#grid_waregroups tbody tr:first-child').click();

I know and I see other examples where setSelection is used and it worked perfektly ... but in my code it does it not ;( If you need some code just say it I will give it to you.

Greetings from Germany

01/04/2010
17:05
Avatar
aime42
France
New Member
Members
Forum Posts: 2
Member Since:
01/04/2010
sp_UserOfflineSmall Offline

Hi,

I have a similar problem. I would like to select the first row after a grid reloading.

What I tried did not do what I expected.

Here is my code :

$("#accountGrid").jqGrid({
    url: g_account_url,
    datatype: "json",
    caption: "AccountList",
    colNames:[ "account_id", "Label", "Currency", "Balance" ],
    colModel:[
        {name:"account_id",index:"account_id", width:1, hidden:true, key:true},
        {name:"account_label",index:"account_label", width:180},
        {name:"currency_code",index:"currency_code", width:180},
        {name:"balance_amount",index:"balance_amount", width:180},
    ],
    height: "150px",
    autowidth: true,
    onSelectRow: f_select_account,
    loadComplete: function(){
        $("#accountGrid").setSelection($("#accountGrid").getDataIDs()[0],true);
    },
    gridComplete: function(){
        $("#accountGrid").setSelection($("#accountGrid").getDataIDs()[0],true);
    }
});

Thanks for your help,

Regards,

Aime

01/04/2010
17:42
Avatar
phamtranquocviet
Member
Members
Forum Posts: 22
Member Since:
06/02/2010
sp_UserOfflineSmall Offline

Thanks Tony. Your workaround work for me.

I reset url to aAction=RefreshData before reloadding the grid because  want to force server to query db. There are other cases where aAction=loadData which can be either query db if never queried before or reuse data stored in session if queried before. Just to save some performance.

Thanks again.

03/04/2010
17:16
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

@unknown

try this instead

$('#grid_waregroups tbody tr:first').trigger("click");

Note that I replace first-child with firs.

@Aime

a gridComplete should be used only. It is quiet possible that in loadComplete the row is selected, but in gridComplete it will be deselected – the setSelection is a toggle function.

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/04/2010
17:14
Avatar
aime42
France
New Member
Members
Forum Posts: 2
Member Since:
01/04/2010
sp_UserOfflineSmall Offline

Thanks Tony,

Using only gridComplete works fine for me now.Cool

Regards,

Aime

25/05/2011
20:16
Avatar
dluis
Member
Members
Forum Posts: 19
Member Since:
09/11/2010
sp_UserOfflineSmall Offline

I'm having the same problem with version 4 of JQGrid.

What I found was that after a trigger("reloadGrid"); the setSelection scrolls to the position, selects the row in the background BUT it will not make the selection visible. Only after I sort the data or click refresh it will select the item. My grid type is JSON.

I know that the setSelection in the background selects the row because I have a reload of another grid onSelectRow. That problem here is that the Row is not getting the CSS Classes ui-state-hover ui-state-highlight.

UPDATE: Just found that If I call  $("#grid").jqGrid("resetSelection"); before the SetSelection the Selection is made in the GridComplete!

22/11/2011
15:21
Avatar
alb84
Member
Members
Forum Posts: 5
Member Since:
21/09/2011
sp_UserOfflineSmall Offline

I have a jqGrid created when my page loads.

When I update or delete a row I use the methods setRowData or delRowData to update the grid withour reloading it.

Yet when I add a row, I cannot use addRowData because the sorting is wrong.

So I add the row in the database and then reload the grid.

But I want the new inserted row selected.

So I call setSelection, but the reloadGrid fires after the setSelection and so my row is not selected.

So I need to assign a callback to the loadComplete event, but my grid is already created when I want to assign the callback to the loadComplete event... is there a way to do this?

23/11/2011
08:35
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

You canb call setSelection AFTER reload the grid and not before.

Also a good choice is to call setSelection with setTimeout function to give a grid a time to refresh its data.

Regards

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/2013
21:20
Avatar
jplevene
London
Member
Members
Forum Posts: 13
Member Since:
08/11/2012
sp_UserOfflineSmall Offline

You are all making a simple mistake.  To select the first row in the jqgrid after the data has loaded use the following:

gridComplete: function()
{
// Select second row as first is the title
$("#grid tr").eq(1).trigger("click");
}

Laugh

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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