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!
|
|
Grid Control - Staying on the Same Row
Posted: 03 Dec 06 5:17 PM
|
fiogf49gjkf0d I have a grid control where Edit loads a Data Form. When the user Clicks Okay and the system returns to the Grid Control it puts the user on the bottom most record of the control instead of keeping them on the record they edited. Any ideas why? |
|
|
|
Re: Grid Control - Staying on the Same Row
Posted: 04 Dec 06 9:11 AM
|
fiogf49gjkf0d It's the way it works The grid gets (auto) refreshed and goes back to it's initial state. Now you could capture the PKID ( IdIwasEditing = datagrid.GetCurrentField ) and then re-position yourself after the edit is complete by trapping the OnEdited event.
I'd probably simplify it by launching the Edit Form via code and not "bound" using Application.MainViews.AddEx and capture the Result> .. something like: iResult = Application.MainViews.AddEx(Form,0,True,True,ID,"") If iResult = mrOK then ... user clicked ok Else ..user canceled End If
..Get the idea? -- rjl
|
|
|
|
Re: Grid Control - Staying on the Same Row
Posted: 04 Dec 06 11:50 AM
|
fiogf49gjkf0d You can control that by saving the selection, then set the selection back after the form closes. Loop through DataGrid1.Selection and save those values, then set them back by adding each value back to DataGrid1.Selection.Add(savedId). |
|
|
|
Re: Grid Control - Staying on the Same Row
Posted: 04 Dec 06 1:59 PM
|
fiogf49gjkf0d Couple of things in reply to both posts actually: 1) .Selection was a 6.2 introduction I believe. It requires multiselect = true. I believe it also requires the primary key to be invisible at column 0. 2) Grid.GetCurrentField("") works without the need of an invisible column but I believe it doesn't work with multiselect = true. It should be an either/or scenario.
The technique I use for a similar outcome is to place a stringKeyFieldValue variable outside all routines. I then use OnEditingRow to set stringKeyFieldValue = Sender.Selection (or GetCurrentField("") depending on the need). Then all you'd need to do is set your OnEdited event to repopulate the selection.
Incidentally, I also trap a temporary value using OnEdited during inline editing. This lets me go back in the case of a validation problem with the new value. |
|
|
|
Re: Grid Control - Staying on the Same Row
Posted: 05 Dec 06 10:50 AM
|
fiogf49gjkf0d I've been struggling with a similar problem in 6.2, and have finally found a solution so figured I'd add it to this thread. I have a datagrid that I am setting SQL and column properties at runtime. The user can right-click on the selected row (multiselect=false) and open a lookup. After completing the lookup, the recordset in the datagrid is refreshed. I want the selected row to continue to be selected using DataGrid1.Selection.Add stringKeyFieldValue, but the &$#*! datagrid kept returning to the first row! I searched around for methods to get this to work until I found a post relating to a datagrid's Sortable property. Because I am setting the SQL and adding columns at runtime, the Sortable=true property must be set in code _after_ these steps. Adding DataGrid1.Sortable = true solved the problem . From threads on CRMToolbox, this appears to be a change in 6.2 from previous versions (or maybe just SP3?), wherein the datagrid doesn't load all of the records unless Sortable is true. |
|
|
|
Re: Grid Control - Staying on the Same Row
Posted: 06 Dec 06 1:43 PM
|
fiogf49gjkf0d When a grid is updated, typically the recordset would only hold the updated value. I ran into this issue because I used a listview with checkboxes to simulate a multi-select grid back in 6.1. I had a nice time trying to debug why it happened and it never occured to use sortable = true (or anything that would load the entire recordset into memory). I believe what happens is the grid caches the information in an internal structure. Sortable = true just makes sure the recordset retains a copy of this structure.
There are definitely some "pitfalls" when doing certain things with the grid. It's kind of a shame no one's really documented them in one place. |
|
|
|
Re: Grid Control - Staying on the Same Row
Posted: 06 Dec 06 2:13 PM
|
fiogf49gjkf0d Originally posted by Rick Smith
...wherein the datagrid doesn't load all of the records unless Sortable is true. |
|
Sounds like a problem with virtual server-side cursors. When you sort a column (non-indexed) it causes the VSSC to retrieve all rows so they can be sorted. Otherwise it is only paging in sets of records - as you scroll down a grid it is continually retrieving more records as needed. The VSSC implementation will only retrieve all primary key values from the results and then retrieve the other fields as needed. Not sure what that means for your issue, but they sure sound related. You can force the grid to not use VSSC. Maybe that would fix the problem? |
|
|
|
Re: Grid Control - Staying on the Same Row
Posted: 07 Dec 06 7:36 AM
|
fiogf49gjkf0d Hey Ryan, you have me curious now. How would you disable VSCC for a specific grid? The "Sortable" property appeared to be the mechanism to do this, but sounds like there is another way... |
|
|
|
Re: Grid Control - Staying on the Same Row
Posted: 07 Dec 06 8:58 AM
|
fiogf49gjkf0d The v7 DataGrid actually has a property called "UseVSSC" you can check or uncheck to force either way (although checking it to force a VSSC the normal rules for a VSSC still apply) |
|
|
| |
|
Re: Grid Control - Staying on the Same Row
Posted: 08 Dec 06 7:56 AM
|
fiogf49gjkf0d Originally posted by Ryan Farley
The v7 DataGrid actually has a property called "UseVSSC" you can check or uncheck to force either way (although checking it to force a VSSC the normal rules for a VSSC still apply) |
|
Word of warning on using VSSC on a datagrid: It's a ReadOnly deal w/fwd/back "scrolling". -- rjl |
|
|
|
Re: Grid Control - Staying on the Same Row
Posted: 20 Dec 06 2:53 PM
|
fiogf49gjkf0d We are using v 6.1.2.
I have a tab that lists items in a grid. My process allows the user to create a new item. When a new item is created I need the grid to refresh and to have the new item selected.
I am have a (*$(* of a time getting the new item selected.
Any hints? |
|
|
| |
|