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!
|
|
Update Datagrid - SOLVED
Posted: 18 Feb 10 6:50 AM
|
Hi All, i have carried out a customisation so we can record changes to the adjusted price and quantity of a product in the Opportunity:Products datagrid.
I have locked the datagrid down so to make changes the user must right click and choose edit. This then opens a form i have made where they can edit the product's adjusted price and quantity.
Once the user has made their chnages they click the ok button which saves the changes and creates the history record.
The problem i have is that once the user cicks ok and my form closes the changes do not reflect in the datgrid until either a ctrl+F5 is done or the user navigates to a different record and then returns to the one they edited (a normal F5 does not work).
Does anyone now how i can get the datagrid to autmatically show the updated values when my edit form closes? |
|
|
|
Re: Update Datagrid
Posted: 19 Feb 10 3:43 AM
|
Below is a code sample from one of Ryan Farley's articles (http://findsellserve.com/page.aspx?action=viewarticle&articleid=32). You can try putting this in your Edit form right after the data is saved. Sub frmAccountDetail with the correct form name. Then, instead of frm.txtAccount.Text, you can try frm.dgGrid.Refresh.
Dim frm ' loop through the forms For i = 0 to Application.Forms.Count - 1 ' check if we've found the Account Detail form. ' make sure you've changed it's Name property. If Application.Forms(i).Name = "frmAccountDetail" Then ' save the reference to this form Set frm = Application.Forms(i) ' now use it to update one of it's controls frm.txtAccount.Text = frm.txtAccount.Text & " - UPDATED" Exit For End If Next
|
|
|
|
Re: Update Datagrid
Posted: 19 Feb 10 4:09 AM
|
Hi Chris,thanks for your reply but unfortunately it didnt work. In the Insert Opportunity Common vbscript there is a function called DoGridCalculations which is hit when you navigate away from the record (or do a ctrl+F5) but it is not hit on the grid.refresh of F5. |
|
|
|
Re: Update Datagrid
Posted: 19 Feb 10 4:35 AM
|
Ive now managed to get my edit form to call dogridcalculations before my form closes but the datagrid still doesnt automatically update. |
|
|
|
Re: Update Datagrid
Posted: 19 Feb 10 6:29 AM
|
Another update but we're getting there!
I now have it so the datagrid will automatically update on the tab view but not if its on the middle pane view. A bit of a cheat but, behind the Opportunity Products datagrid there is a text box called txtDataBound that holds the current OpportunityID. There is a sub on the same form called Sub txtDataBoundChange(Sender) that saves of the changes. So when my edit form closes i update the value of this text box and then revert back to its original vblaue kicking off the Sub txtDataBoundChange(Sender). But it does not update the middle pane view of the datagrid, just the tab view. So still only halfway there |
|
|
|
Re: Update Datagrid
Posted: 19 Feb 10 7:07 AM
|
There is some call SLX uses to refresh middle pane forms...ODV script? It refers to the specific form. Eval DB has it for sure. |
|
|
|
Re: Update Datagrid
Posted: 19 Feb 10 8:27 AM
|
Ive noticed something even more confusing now. If, when you open saleslogix, you have the products datagrid in the middle pane and then ALSO open it as a tab, the middle pane will immediately update but not the tab. And the same thing happens vice versa. If you open saleslogix and you have the products datagrid in a tab and then also drag it to the middle pane the tab updates but not the middle pane! So whichever view (tab or middle pane) you have first gets the automatic update and the other needs the refresh (or navigate to next record and then go back has same result). Below is the code i use when my edit form closes: Dim frm Dim i ' loop through the forms For i = 0 to Application.Forms.Count - 1 ' check if we've found the Opportunity Products form. If Application.Forms(i).Name = "frmOppProducts" Then ' save the reference to this form Set frm = Application.Forms(i) ' now use it to update one of it's controls Dim a a = frm.txtDataBound.Text frm.txtDataBound.Text = frm.txtDataBound.Text & "a" frm.txtDataBound.Text = a frm.grdProducts.Refresh Application.BasicFunctions.RefreshMainView Exit For End If Next
|
|
|
|
Re: Update Datagrid
Posted: 19 Feb 10 10:58 AM
|
FINALLY!!!!! got it to work.
For the curiousity of those who helped (thanks all) this is the code i execute on the closing of my edit form:
Dim frm Dim i ' loop through the forms For i = 0 to Application.Forms.Count - 1 ' check if we've found the Account Detail form. ' make sure you've changed it's Name property. If Application.Forms(i).Name = "frmOppProducts" Then ' save the reference to this form Set frm = Application.Forms(i) ' now use it to update one of it's controls 'Set frm.grdProducts.Recordset = DoGridCalculations (frm.grdProducts, "", "", frm.CurrentID) 'frm.grdProducts.PostChanges Dim a a = frm.txtDataBound.Text frm.txtDataBound.Text = frm.txtDataBound.Text & "a" frm.txtDataBound.Text = a frm.grdProducts.Refresh Application.BasicFunctions.RefreshMainView
Dim objActiveView,objMiddleView,objTabView Set objActiveView = Application.MainViews.ActiveView Set objMiddleView = objActiveView.MiddleView If Not (objMiddleView Is Nothing) Then If objMiddleView.Name = "frmOppProducts" Then
Set objTabView = objActiveView.TabsView Set objMiddleView.grdProducts.RecordSet = DoGridCalculations (frm.grdProducts, "", "", frm.CurrentID) 'need an if here to check that the products tab is open if objTabView.name = "frmOppProducts" then Set objTabView.grdProducts.RecordSet = DoGridCalculations (frm.grdProducts, "", "", frm.CurrentID) else end if objMiddleView.refresh else
end if end if Exit For End If Next
|
|
|
|