11/26/2024 6:21:29 PM
|
|
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!
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.
|
|
|
|
Datagrid doesn't refresh
Posted: 23 Oct 06 8:53 AM
|
fiogf49gjkf0d Hi, My datagrid ( in a popup, I'll explain later on) doesn't refresh although the refresh command is fired.
I have the Agreements datagrid in mainview. From here I add a record (new Agreement (this is on contact level)), then a popup with all the info appears. There are three datagrids on it each in relation with a one-to-many table. I can't add anything to the datagrids unless I know the new agreement ID. This I've taken care of. Now I want to add a new record to one of the datagrids. Another popup appears. I passed the new Agreement ID through with a Global var. I can add a record but It doesn't refresh so I don't see it. It does pass the AddedRow in the script but seems to ignore the grdMain.Refresh command I put there and all the other commands I tried.
The same thing happens with the mainview datagrid. When I add a record I doesn't auto refresh.
In both situations I have to add the records manually with a SQL statement. Does this has anything to do with it? |
|
|
|
Re: Datagrid doesn't refresh
Posted: 23 Oct 06 4:54 PM
|
fiogf49gjkf0d I think of the relationship in generations. The parent grid, the child form, and grandchildren grids on the child form. The KeyField value on every data form links it to the created record. This is tied to the BIND ID of the datagrid and basically creates this basic query: "select from gridtable where tableid = bindid" (I probably have the statement backwards, but hopefully you get the point). When you create a new child record, the KeyField value for the form is BLANK. You can create a record through straight SQL but the keyfield value won't change.
I tackle the problem by using SLX's built in functionality for datagrids. Each record in the chain is created automatically, I use no SQL statements to create them. Here's my PostNewRecord function:
Function PostNewRecord dim booleanIsFormValid dim booleanResult On Error Resume Next booleanResult = false if (booleanIsNewRecord) then ' Validate before Posting booleanIsFormValid = AXFormValidate(oAXForm) if (booleanIsFormValid) then stringTableKeyFieldValue = Application.BasicFunctions.GetIDFor(oAXForm.BaseTable) textBoxTableKeyField.Text = stringTableKeyFieldValue ' Post current information oAXForm.Post oAXForm.Refresh if (buttonCancel.Enabled) then buttonCancel.Enabled = false end if booleanResult = true end if end if PostNewRecord = booleanResult ErrorCheck(Application.Translator.Localize("PostNewRecord:")) On Error Goto 0 End Function
I call this function in the OnAddingRow event of EVERY data grid on the child form. I first call AXFormValidate (OnValidate) to make sure the record is valid before posting. I call GetIDFor to increment the primary key value and place it in a control called textBoxTableKeyField. This control's .Text property is bound to the primary key, in your case AgreementID (not necessary but helpful for programmatic reasons). Form.Post and Form.Refresh emulates clicking OK, having SLX create the record, finding the record in the grid, then editing it. oAXForm is defined in the OnCreate event of the form like this: set oAXForm = Sender. Basically this allows me to use oAXForm instead of formWhatever, keeping me from changing the hardcoded value every time I copy this routine somewhere else.
From this point on I'm allowed to create a child record normally. If you have many levels in your hierarchy you can reuse the technique to make sure each parent in the chain is created before the child form pops up. If you're familiar with computer science fundamentals, it's the equivalent of creating a linked list.
Personally, I consider this the greatest technique in my arsenal. I use it in very few places but it allows me to leverage SLX instead of trying to keep a bunch of SQL tightly-coupled across multiple forms. The technique is only beneficial for data forms, as manage forms aren't tied to a table. |
|
|
|
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!
|
|
|
|
|
|
|
|