Not retaining values after save - jqgrid

In my application I am using jqGrid to display the data from database, user can update the values and save the data in database. I have a paging in the grid.
I want to implement 2 things --
--- After I save values in the database, jqGrid columns become blank. I want to retain the values in column after save.
--- When I update the values on one page and goes to second page and again I come back to first page, I want to retain the values on the first page.
Is that possible?

If you edited data locally (on grid which has datatype: "local") then you can use grid.jqGrid("getGridParam", "data") to get the current (modified) data. you can send the data to the server via $.ajax call.

Related

Refreshing Interactive Grids with JavaScript using row-refresh action

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.

How to reload row in datatables

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

How can I figure out the value of the clicked cell in a table which was generated in ASP?

I'm generating a large table on a webapp using ASP. I connect to an oracle database using ADODB.Recordset and fill a table with each row of data. Whenever you click on the ID number (the first column of each row), there are 15 boxes at the bottom that will fill up with more data from the database. I apologize for censoring the data, but you can see what I'm giong for. The table fills up with data, and then there's another table at the bottom that, when an ID number is clicked, should fill up with more info for that Id.
The problem I'm having is that, as the Recordset is stepped through to fill up the table, it gets to the end and keeps pointing at the last record in the database. I need to find a way to make it point at the record I clicked on so that it can get all of the data about that record. Any ideas how to do it?
Only 2 ways I know of that will do what you want.
Using JavaScript as #Ed suggested. This will give you results in
your bottom table without a page refresh.
Using VBScript, generate a URL with a querystring with the ID you
want. Use the ID to populate your bottom table. This will require a
page refresh.

Is there a way to force a single row refresh with SlickGrid?

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

Deleted row in jQgrid returns when grid is reloaded or grid is paged

I have a grid, to which I'm making a delRowData(rowId) call to, whenever the grid gets reloaded using .trigger('reloadGrid') the deleted row returns, I can access the grid data and delete it from there, but I'd prefer not to, if I can avoid it.
To note, I need to reload the grid as I have custom subgrid tabs that get out of alignment when the row is deleted. The row also returns when I change pages on jqgrid's pagination.
Any suggestions?
.delRowData() function only deletes the row from clientslide if you don't use datatype: "local", once you trigger grid reload, it will get the data again from the server to fill your grid. So you can first delete the row on your server side, then in the jquery.ajax callback function you can invoke .delRowData() or some other function like this.

Resources