tonytomov / jqGrid

jQuery grid plugin
www.trirand.com
2.84k stars 1.2k forks source link

[QUESTION] How to update/reload ViewGrid_ID after change the same row displaying? #1027

Closed parallels999 closed 1 year ago

parallels999 commented 1 year ago

I don't kown if it is an issue,

If I open the modal with ViewGridRow it show a form with the data of the one row, if an event changes that grid row data(on background when modal is open), the modal keeps old data, is there a way to reload the open modal data with the row updated data from my event?

Like next/prev, i use the those buttons forward and backward for reload the row, but I don't know if there is a way to do it directly on my custom event

I did try viewGridRow again with the same rowId but not reloads the data, and fails (creates &times icons each time) image

tonytomov commented 1 year ago

You will need to set recreateForm to true in viewGridRow options. See View grid row

parallels999 commented 1 year ago

You will need to set recreateForm to true in viewGridRow options.

I forgot to mention that I had already tried recreateForm and it doesn't work correctly Also, still the close button image

tonytomov commented 1 year ago

It seems I do not understand correctly the issue.

Can you please describe step by step in detail what you do?

If I this time understand correct, one possible solution is to trigger the next button row and then the prev button row to reload the data.

The id of these buttons are nData and pData and you can do something like this:

$("#nData", "#viewmod"+gridID).trigger("click"); $("#pData", "#viewmod"+gridID).trigger("click");

where gridID is the id of the grid and be a sure you are not in the first and in the last record .

Just to know that there is a function which do exactly this, but it is not public and you can not call it outside of the method

parallels999 commented 1 year ago

If I this time understand correct, one possible solution is to trigger the next button row and then the prev button row to reload the data

Yes, but when there is only one row, there is not next, prev button enabled

Just to know that there is a function which do exactly this, but it is not public and you can not call it outside of the method

It would be great to be able to use it.

Can you please describe step by step in detail what you do?

Imagine a small table with many hidden columns, with ViewGridRow I show all the hidden columns, there is a process that performs calculations based on some event on random time or maybe a websocket in real time, then in that event I change the row data on the grid, but the data in the modal that was already open cannot be manually updated to match the data in the grid, the next, prev trick doesn't work in 100% of cases(Only one row, check first or last row)

tonytomov commented 1 year ago

I have created two methods refreshViewForm and refreshEditForm to refresh the form in background.

To use the method use the following

var grid = $("#jqGrid")[0];
// update here the grid row your way and the
try {
    grid.refreshViewForm( id);
} ctach (e) {
}
// in case of edit row
try {
    grid.refreshEditForm( id);
} ctach (e) {
}

Please note the calling convention and the try catch block Please let me know if this work for you.

Regards

tonytomov commented 1 year ago

Hello,

I have added second parameter force to prevent updating the current loaded record in the form. If you set the second parameter to true the data of the form will be replaced with the id provided instead that it differ from the current loaded one.

Regards

parallels999 commented 1 year ago

Great, it is working now, it also avoid close button icon issue

Thank you very much