Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Highlighted
Astute Commentator
Posts: 16
Registered: ‎04-15-2009

datagrid does not refresh on records change

Hi Everyone

 

I created an Account form with a datagrid in it.

The entry, edit and delete are all working fine.

When toggling between the accounts records, it does not refresh the grid data, still displays the last entry.

It only updates the information after an F5 or after switching to a different tab.

I added the Datagrid.Refresh command on almost every possible event. But it still does not refresh it until I hit F5.

 

Any ideas?

 

Thanks

 

Oren

 

 

 

 

Highlighted
Gold Super Contributor
Posts: 3,087
Registered: ‎03-19-2009

Re: datagrid does not refresh on records change

If you have not set a conditional and set a BINDID than the only way to refresh is on the AXFormChange event.. not any of the events on the grid itself.

--
RJ Ledger - rjledger@rjlSystems.net +1 603.369.3047 x101

".. Innovators in Mobility - Experts in Workflow Automation..."
http://www.rjlSystems.net - blog: www.rjlSystems.net/blog.html
Highlighted
Astute Commentator
Posts: 16
Registered: ‎04-15-2009

Re: datagrid does not refresh on records change

Hi RJ Ledger

 

Thank you for the prompt reply.

I do have a bindid: (ACCOUNT:ACCOUNTID)

And I also added to command to refresh the grid on form change

 

Sub AXFormChange(Sender)
   gridValues
   grdForecastDesignWin.Refresh
   grdForecastSales.Refresh
End Sub

Sub AXFormOpen(Sender)
   gridValues
   grdForecastDesignWin.Refresh
   grdForecastSales.Refresh
End Sub

Sub AXFormCreate(Sender)
   grdForecastDesignWin.Refresh
   grdForecastSales.Refresh
End Sub

 

I tried all of the above.

there are 2 grids on the form:

 

grdForecastDesignWin
grdForecastSales

 

Also 

I call the sub that sets the grid values on almost any thinkable form event:

 

 

Form properties:

OnBeforeRecords: gridValues

OnCreate: gridValues

OnDestroy: gridValues

OnOpen: gridValues

OnRefresh: gridValues

onShow: gridValues

 

Any ideas????

 

Thanks a lot for looking into this.

 

Oren

Highlighted
Gold Super Contributor
Posts: 3,087
Registered: ‎03-19-2009

Re: datagrid does not refresh on records change

Post your grid sql....

If it's done as a normal/typical bound grid.. then there's NO need for any code behind. It's all built-in to handle a "bound grid"...

--
RJ Ledger - rjledger@rjlSystems.net +1 603.369.3047 x101

".. Innovators in Mobility - Experts in Workflow Automation..."
http://www.rjlSystems.net - blog: www.rjlSystems.net/blog.html
Highlighted
Silver Contributor
Posts: 835
Registered: ‎03-24-2009

Re: datagrid does not refresh on records change

also make sure your AXForm event handlers are actually listed in the Forms properties!!! AXFormChange will not fire unless it's wired into the form's event handers....and a NON TICKET\Support form (which fires an AXSupportFormChange)!

 

If you have a BINDID, and a Linked field in the SQL for the Grid, SLX will actually fire off the Refresh TWICE for you. Absolutely NO NEED for a Grid.Refresh (which would be a THIRD refresh\Query of the database).

 

The Classic for me is:

1. BINDID

2. Link field to the BindID in the SQL (which it sounds like you are not doing this)

3. grid.sql.text ="adfadfadfasdfdf"

4. Grid.Refresh

 

In the SAME Form.

 

99% of SLX developers out there do not realize this is 4 refreshes of the SLX database, i.e. 4 round trip SQL queries and refreshes of the grid.

 

And you are potentially firing off 6 refreshes for your two grids......

 

 

 

RJ Samp
Highlighted
Astute Commentator
Posts: 16
Registered: ‎04-15-2009

Re: datagrid does not refresh on records change

Hi RJSamp

 

Here is the Grid Subroutine

 

 Dim SQL, cUserID, myAccountID, SQL2
    CUserID = Trim(Application.basicfunctions.currentuserid)

    myAccountID = Application.BasicFunctions.CurrentAccountID



SQL2 = "SELECT A1.C_FY, A1.C_FQ, A2.C_PRODUCTLINEDESCRIPTION A2_C_PRODUCTLINEDESCRIPTION, A1.C_REVENUE,A1.C_GP_PERCENT, A1.C_GP_DOLLARS, A1.C_OSR_USERID, A1.C_CM_ACCOUNT_NAME, A1.C_ACC_FORECAST_SALESID " &_
           " FROM C_ACC_FORECAST_SALES A1 LEFT OUTER JOIN C_IM_PRODUCTLINE_MAS A2 ON (A1.C_PL_CODE=A2.C_PRODUCTLINECODE) " &_
           " WHERE A1.ACCOUNTID = '" & myAccountID & "' AND A1.C_OSR_USERID = '" & CUserID & "' ORDER BY A1.C_FY DESC, A1.C_FQ DESC, A2.C_PRODUCTLINEDESCRIPTION ASC "

    grdForecastSales.BindID = myAccountID
    grdForecastSales.sql.text = SQL2

 

Can you be more specific about number 2 on you list: "Link field to the BindID in the SQL (which it sounds like you are not doing this)"

 

I think I'm doing that here:

grdForecastSales.BindID = myAccountID

 Anything I'm missing.

 

 

Thanks again

 

Oren

 

Highlighted
Silver Contributor
Posts: 835
Registered: ‎03-24-2009

Re: datagrid does not refresh on records change

If you are doing this in SQL then you don't need to populate the BINDID property in the grid.

 

If you have NO databound fields on the form (like explicitly through the BINDID property of the grid) then you will NEVER fire an AXFormChange.

 

i always create (for Account forms) a TheAccountID Edit box, invisible, colored red, databound to Account:AccountID. This databinding will fire off the wired AXFormChange of the form.

Then instead of this: "myAccountID = Application.BasicFunctions.CurrentAccountID"

use this:

myAccountID = "" & Trim(TheAccountID.TEXT)

 

Then you put your SQL script in the AXFormChange subroutine.

 

Put a Message Box in your AXForm Change to make sure it's firing off.....every time you go to another Account.

RJ Samp