Thought I would pass this along in case someone encounters the same issue I did.
I have a grid which uses an auto-increment integer as the primary key, but is ordered by one of the character fields. Thus, the grid displays the data in alphabetical order of the field, not in primary key order.
However, when adding a new record, I found the new record was always inserted at the end of the list, and thus I would have to refresh the grid to show it in the proper position. So I tried adding in a "{grid.object}refresh();" command into the Ajax array that is returned in the "After Insert Record" event of the grid. However, this would almost always give me a message that I had to "Save or Cancel Edits to the Grid before continuing" message. I presume that the refresh was attempting to execute before the server had actually completed the save.
I found that I could avoid this problem by adding a command to essentially refresh the "order by" clause of the grid, by inserting the following into the "After Insert Record":
With this addition, the grid would insert the new record and then apply the Order By clause immediately in the grid.
This also works in the After Update Record, in the case where an update is made to the field which is involved in the Order By Clause.
Hope this saves someone some time.
In retrospect, I guess I could have simply made the field I wish to sort by a primary key, and possibly have avoided this whole problem to begin with...
I have a grid which uses an auto-increment integer as the primary key, but is ordered by one of the character fields. Thus, the grid displays the data in alphabetical order of the field, not in primary key order.
However, when adding a new record, I found the new record was always inserted at the end of the list, and thus I would have to refresh the grid to show it in the proper position. So I tried adding in a "{grid.object}refresh();" command into the Ajax array that is returned in the "After Insert Record" event of the grid. However, this would almost always give me a message that I had to "Save or Cancel Edits to the Grid before continuing" message. I presume that the refresh was attempting to execute before the server had actually completed the save.
I found that I could avoid this problem by adding a command to essentially refresh the "order by" clause of the grid, by inserting the following into the "After Insert Record":
Code:
aa = e.rtc.A_AjaxResponses aa[1].text = "{grid.Object}.gridFilterSet('','ServiceDate DESC')"
This also works in the After Update Record, in the case where an update is made to the field which is involved in the Order By Clause.
Hope this saves someone some time.
In retrospect, I guess I could have simply made the field I wish to sort by a primary key, and possibly have avoided this whole problem to begin with...
Comment