Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Tuesday, November 26, 2024 
 
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: Select grid row through code
David Saggio
Posts: 20
 
Select grid row through codeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Nov 06 7:19 AM
fiogf49gjkf0d
I know this is a basic question, but how can I programatically select a specific row in a grid? I have looked and just can't figure it out.

Thanks,

Dave
[Reply][Quote]
John Rogerson
Posts: 7
 
Re: Select grid row through codeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Nov 06 7:31 AM
fiogf49gjkf0d
You need to have the KEYFIELD property set to the unique field of the table that the grid is attached to.
That field needs to be present in the grid layout. Whether it is visible or not is up to you.

Then you can say

grdMyGrid.Selection.Add strID

unless I've missed something, that should do it.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Select grid row through codeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Nov 06 10:32 AM
fiogf49gjkf0d
John's suggestion is spot on, however, I wanted to add a couple of points. The ability to select a row programatically IIRC was introduced in version 6.2, so in pre-6.2 versions you'll be out of luck.

Secondly, you have to add the table's primary key column to the grid. The table's primary key field will be accessible by default with the grid, but that is not enough, you have to add the field to the layout and then hide it - otherwise you can't set or read the selected rows since it relies on this column being in the grid's layout.

-Ryan
[Reply][Quote]
David Saggio
Posts: 20
 
Re: Select grid row through codeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Nov 06 2:34 PM
fiogf49gjkf0d
I tried this but it doesn't appear to be actually selecting the entire row in the grid. What I would like is as if i selected the row with my mouse.

Dave
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Select grid row through codeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Nov 06 2:43 PM
fiogf49gjkf0d
Quote:
Originally posted by David Saggio

I tried this but it doesn't appear to be actually selecting the entire row in the grid. What I would like is as if i selected the row with my mouse


Not sure I follow. When you say "it doesn't appear to be selecting the entire row" what do you see is happening?

Using
grdMyGrid.Selection.Add strPrimaryID


is the way to select a row. Also, if you want it to have the appearance that the entire row is selected (and not just some cell) then make sure the RowSelect property is set to true.
[Reply][Quote]
David Saggio
Posts: 20
 
Re: Select grid row through codeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Nov 06 4:50 PM
fiogf49gjkf0d
Here is the way that I am testing for each item in the grid:

grdMyGrid.Selection.Add KEYFIELDID
strCrntRecord = grdMyGrid.GetCurrentField("KEYFIELDID")
msgbox strCrntRecord

This just keeps displaying the first record in the grid.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Select grid row through codeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Nov 06 5:54 PM
fiogf49gjkf0d
AFAIK GetCurrentField doesn't play well with the Selection collection, but it's been a while since I tested that. The Selection collection was added mostly for multi-select functionality. So adding to the Selection collection (which is the only way to select a row) assumes (albeit incorrectly) that multiple rows are, or could be, selected - which GetCurrentField doesn't work for. Know what I mean? BTW, I'm not saying that this doesn't suck, because it does.

BTW, does it visibly select the row in the grid? Or does it just not return the expected values when using GetCurrentField?
[Reply][Quote]
John Rogerson
Posts: 7
 
Re: Select grid row through codeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Nov 06 8:15 AM
fiogf49gjkf0d
You could try

grdMyGrid.Selection.Clear

before you do the .Add
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Select grid row through codeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Nov 06 2:17 PM
fiogf49gjkf0d
Selection does NOT work unless multiselect is enabled. You could say that the GetCurrentField and Selection methods are polar opposites. I've never been able to use both on one datagrid before but that may just be me.
[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 © 2024 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): 11/26/2024 10:45:59 PM