Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, August 29, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Programmatically select row in datagrid
Guy Barrett
Posts: 63
 
Programmatically select row in datagridYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Aug 09 9:29 AM
Hi all (again),

In the legacy version of Saleslogix, you could select "edit" from a grid item, make your changes to the window that popped up, click ok, and the item in the grid you just edited would be highlighted still. This would also work when "add"ing an item.

However, in 7.2 (not sure about 7.5, I haven't got that far yet). When you do the same you are returned to the beginning of the list. Also, if you refresh the grid for any reason, you are returned to the beginning of the list and not on the item that was previously highlighted.

Is there any way to programmatically (and quickly) change the row selected on a grid by the unique id of the record on the grid?

I have been using the method outlined below, but this only really works for small datasets as it takes ages for it to step through larger ones row by row. Someone also offered a solution involving ticking the "Sortable" property in the datagrid properties (to load the whole dataset into memory) but this also did not work.

CURRENTLY USING

sub Grid_SelectRowByID (grdGRD, strID)

'*** THIS CRAZY LITTLE FUNCTION LEGS IT THROUGH THE GRID UNTIL IT REACHES THE ITEM WE EDITED.
'*** IT SUCKS, BUT IS CURRENTLY THE ONLY WAY TO DO IT.

dim strID_CURRENT
dim intROW_CURRENT
dim intROW_MAX
dim objWSCRIPT

Set objWSCRIPT = Application.CreateObject("WScript.Shell")
grdGRD.Refresh
intROW_MAX = grdGRD.NodesCount
grdGRD.SetFocus
Application.DoEvents
intROW_CURRENT = 1
strID_CURRENT = grdGRD.GetCurrentField("PRODUCT_CATID")
While strID_CURRENT <> strID and intROW_CURRENT <= intROW_MAX
objWSCRIPT.SendKeys "{DOWN}"
Application.DoEvents
strID_CURRENT = grdGRD.GetCurrentField("PRODUCT_CATID")
intROW_CURRENT = intROW_CURRENT + 1
WEnd
Set objWSCRIPT = Nothing
end sub

Come on Raul, you know you're up for a challenge.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Programmatically select row in datagridYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Aug 09 9:49 AM
I know that there are many issues around the DataGrid between versions, so this may not work on 7.2 (I don't have access to a 7.2 system right now), but it does work on 7.5:

DataGrid.Selection.Add("ROWID")

[Reply][Quote]
Guy Barrett
Posts: 63
 
Re: Programmatically select row in datagridYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Aug 09 10:02 AM
I tried it, no error messages, but it doesn't do anything (at all) either. Do I have to do something to the grid first, like tick "Sortable" or something like that? There's nothing in the Developers Ref about it either

I also put a DataGrid.Selection.Clear in first as well as it is a multiselect grid, and I only want to highlight the one item that was just edited.
[Reply][Quote]
Guy Barrett
Posts: 63
 
Re: Programmatically select row in datagridYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Aug 09 10:06 AM
If the row is in the immediate view of the grid (ie. you don't have to scroll down to it) your method works. However, if it is outside the immediate viewable area of the grid, it won't select it. I've tried this with "sortable" on and off.

Hmmmmm.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Programmatically select row in datagridYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Aug 09 10:33 AM
Here is where the difference in version comes into play:

In 7.5 it will work, but requires Sortable.

The whole reason for it is that the data on the Grid isn't completely loaded, thus it cannot find the item to select. When you apply the Sortable property, it will load the whole resultset to be able to sort it, thus allowing you to set the selection past the current set of visible items.

(Additionally, do not select the UseVSSC as it will also cause the grid to not load all the data.


Now, the downside, the grid will be much slower to load and refresh....

[Reply][Quote]
Guy Barrett
Posts: 63
 
Re: Programmatically select row in datagridYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Aug 09 10:48 AM
Looks like I'll have to upgrade soon then. Thanks for your help Raul

If anyone else has managed to get around this in earlier versions please do let me know, to me it seems like it should be a no-brainer that the grid should be able to do this.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Programmatically select row in datagridYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Aug 09 10:56 AM
Its been tried by many, but your current code is probably as good as it gets.

Another alternative may be to load your query into a Recordset and then attach the recordset to the Grid. Since the whole recordset is available, it may be possible to then set the selected node programatically and have it presented on the screen.
[Reply][Quote]
James Jury
Posts: 23
 
Re: Programmatically select row in datagridYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Aug 09 3:46 AM
I seem to remember experiencing difficulties with the Selection.Add, which were resolved by adding the key as a field to the layout and making invisible (I think it had to be the first in the layout (before hiding)). I could be wrong, but worth a go.

James
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 8/29/2025 1:58:57 PM