I have an interactive grid that intermittently fails to save changed data properly.
I have a changed the default save process into a PL/SQL process to allow me to do some lookups before the data is saved back to the table. I have some PL/SQL logging in the save procedure, so I can see when the process starts & ends and what a number of the variable values are.
This process works fine, most of the time. However every now and again 1 in 20 or so, the process fires but I can see that one of the new values is actually the old value, so the update works with the wrong data. I can not see any pattern to how I'm updating the cell when it doesn't work.
I have created a button with a dynamic action to Submit the page on button click, which fires the update whenever a change is made. I also have a branch on the button at "After Processing".
I'm not sure the branch is relevant as I can see that the save procedure fires before it's redirected, but sometimes without using the updated values.
Any ideas or suggestions on how to track down my issue?
Cheers
Pav
The debug didn't show anything. However I believe I found the cause.
The page had some javascript lifted from the IG Cookbook to calculate a column total.
When I removed one command it stopped the issue. I also tracked the issue to a model change that wasn't saved, then navigated off page and then back. Then the first changed made and saved would save original value and not the changed value.
Code removed was:
// just in case fetch all the data. Model notifications will
// cause calls to update so nothing to do in the callback function.
// can remove if data will always be less than 50 records
model.fetchAll(function() {});
Cheers
Pav
Related
I have a case where updating and saving certain columns in an Interactive Grid row result in some other rows being updated. By default, only the changed row will be refreshed and further changes to (now updated) rows would result in Current version of data in database has changed error. I managed to solve this issue by hooking a Dynamic Action on custom interactivegridsave (which fires after changes have been saved in Interactive Grid). The action itself is Execute JavaScript Code that executes this (note that region_static_id is a placeholder):
apex.region("region_static_id").widget().interactiveGrid("getActions").invoke("refresh");
This will fetch all the records correctly (including the updated ones) and redraw the Interactive Grid. Id'like the changes becoming visible without the redraw. I thought of iterating through the rows, updating each one of them by id using the row-refresh action, but I have no idea how it works (or at least how to invoke it properly). This action should be available as it is properly listed in a list of available actions that I get when i execute this:
apex.region("region_static_id").widget().interactiveGrid("getActions").list().forEach(function(a){console.log("Action Label: "+a.label+", Name: "+a.name+(a.choice!==undefined?", Choice: "+a.choice:""));});
So, the question is:
How can I refresh rows by invoking a row-refresh action in Interactive Grid?
Alternatives that refresh rows (preferably by specifying the row id) are also welcome.
After further research I found an alternative way (which I'm not sure how hackish or stable it is, but it works). It seems you can refresh rows by getting the data grid model, which you then use to fetch all of the its records by using:
var model = apex.region("predmet_dg").widget().interactiveGrid("getViews").grid.model;
model.fetchRecords(model._data);
This way refreshes the data without causing the grid redraw.
I have a data table that represents data like this:
after clicking the edit marker (pencil icon) i can edit some fields. The fields need to be validated and if it fails the fields have to reset. I do this in the managed bean of the view using p:ajax event="rowEditInit" to save the attributes before saving and ajax event="rowEdit"to do the actual validation. if validation fails i return the previously saved values. if validation is correct i save the data to the database and load the collection again. Then i
RequestContext.getCurrentInstance().update("vesselBalticSegmentCreateForm")
to reload the view.
Doesnt matter if the validation fails and i set the values back or it succeeds and i save/reload data the table breaks becoming like this:
seems to load only the edited row. and loads both edit/list modes.
any ideas what i'm doing wrong?
The primeFaces RowEdit functionality already updates the row, also updating the table does by design not work (not sure if it is intentional, but that is just how it is). I know there is a duplicate of this Q/A on stackoverflow, I just do not seem to be able to find it. Someone might be able to create a patch/workaround, e.g. try on the prerenderview event to remove the id's of id's in the individual row that was edited. I don't have the time to try to create one.
I've created a subgrid showing a custom entity Blopp. It shows, the records are viewed as supposed to (related ones only) but I was unhappy with the columns' order and size.
So I went to the solution and made the changes. To my surprise, I discovered that they are not shown when I load the Contact form.
Before anybody jumps up with joy - the save is done, the publish all is done, it's the correct view set in the subgrid and when I pick a different view in the subgrid and then go back to the manipulated one, it shows as supposed to!
What's up with that? The way we're handling it now, we need to remove the subgrid and recreate it again.
What can be the cause and how do I kill it?
I have the amazing SlickGrid configured to access data asynchronously and post user changes back to the server asynchronously. In general terms, the server may modify a few fields of a row based on the user's changes. As such, after the row is updated I would like SlickGrid to refresh only that row without changing the rest of the view.
Does anyone know how to do this?
In my case, the field that changes on the server is a timestamp associated with the record that is updated by a database trigger. If the timestamp is out of date, the user has an old copy of data, and if they submit changes, they may overwrite a new copy. Since I can't find a way to trigger a refresh, the user cannot modify their own changes without refreshing the browser window (forcing a complete refresh).
You should be able to do this using grid.invalidateRow() and grid.render(). SlickGrid will re-render the affceted rows (assuming they are displayed in the currently visible viewport) without refreshing the entire page.
// Mark row 42 as changed and re-render the display
grid.invalidateRow(42);
grid.render();
For an example check out SlickGrid Example 14. (Click the Start Simulation button to see it in action)
function updateSlickgrid() {
dataView.setItems(tableName);
grid.invalidate();
}
Note : tableName could be the array or id etc.
I prefer storing all the slickgrid data in the array ex tableName = [];
Keep using the above function when it comes to displaying the data in slickgrid
I have a grid that is populated by a JSON response (MVC3 controller) that has a userData component for some additional data for grid captions, etc. All that works just fine. I recently switched the the grid's data loading to "loadonce: true" as in working with larger grid results sets, I wanted client-side sorting and filtering. All that works good. BUT, I was surprised that the userData got wiped the first time I clicked any column for sorting. If I turn off loadonce, userData is fine, but it is of course going back to the server each time. The items that make use of the userData fire on gridcomplete and are now coming back "undefined" after a sort (and probably anything that reloads the grid). Any thoughts why this might be happening? Oh yeah, I also noticed that clicking a column sort wiped out any multiselections (perhaps related to the same culprit?).
Thanks,
Mark
You are right. +1 from me. It's a jqGrid bug. Inside of internal addLocalData method after the line 1527 of the file grid.base.js of jqGrid 4.1.2 or after the 1532 of jquery.jqGrid.src.js (you can get modified version from here) one should add the following line
retresult[ts.p.localReader.userdata] = ts.p.userData;
It will fix the problem. I posted the corresponding bug report here.