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.
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 read many posts that talks about this but still I cannot find a clear answer to my question
I need to reload only 1 row when I click on a button
At the moment, I send an ajax request to the server that change a boolean value. The request change the db field but not the table obviously. Now I need to refresh the corresponding table field which is row specific.
$('#table').DataTable().ajax.reload();
This works but it is not quick enough
How can I refresh only the row where the modification happens. Even better if I can refresh only the specific field within the row
Something like this:
$('#table').DataTable().row(rowNumber).data();
I have read that I need to send an ajax request that give me the updated value and put it in the field. I know already what to put but how can I refresh the specific field?
Can you please show me an example
I am using dandelion datatables 1.1.0
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 use primefaces and the dataTable component. On my Site i have several forms which i use to collect Data and persist it in the Database. This is triggered by a p:command Button, which Attribute “Update“ contains the id of the dataTable showing the DB contents. When i submit the Form the component (table) is Not updated. What could be wrong?
not an answer but a question to help divine the point of failure. is the datatable in a separate form from the commandButton? if so, assuming you're using ajax="true" (the default for pf components), how are you referencing the table to make sure it updates. if you're not using ajax, i'm guessing it's a stale data issue in the backing bean. but without more info, it's hard. try attaching source code (stripped down to your comfort level if you're working on something sensitive).
HTH
I have a Model that contains some string fields and a List. In the view I use EditFor for the fields, and want to use WebGrid for the List.
Display works fine. But then I use jQuery client-side to let the user add rows to the table generated by the webgrid, which also show up fine on the UI.
However these rows don't appear to be tied back to my model's List upon a submit. In the controller I see that the posted model's string fields contain whatever was entered by the user. But the model's List is empty - it doesn't contain the original values nor the newly added values.
How can I cause the model posted back to the controller to be fully populated, including whatever the webgrid-generated table looks like now, just like fields are?
I see several other questions like this for webgrid on the forum, but none with an answer.
I suppose you are comming from WebForms world. Well this is different in MVC. Here you are back to plain old html and its input fields. No viewstate to hold your rows. Check this link: http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx.
Basically you need have consecutive index (or ID) for each row.