Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refreshing grid features after editing #953

Closed
unle70 opened this issue Oct 17, 2019 · 16 comments
Closed

Refreshing grid features after editing #953

unle70 opened this issue Oct 17, 2019 · 16 comments
Labels

Comments

@unle70
Copy link

unle70 commented Oct 17, 2019

Hello,
I'm facing 2 related issues which are both happening after editing:

  1. If there's a "cellattr" defined for the edited cell (or for any other cell in the row, but based on the content of the edited cell), it is not refreshed following the editing.
  2. If there's any group summary which considered the edited cell value, it is not refreshed following the editing.

I'm wondering if there is any service function which could be called for refreshing those.
Updating jqGrid to do this automatically would also be very nice.

Thanks,
Udi

@tonytomov
Copy link
Owner

Hello Udi,

Sorry for the delay in the answer - for some reasons I have missed your questions.
I will check the first issue and will let you know ASAP.

As for the second issue - which editing module is used?
If inline or cell edit is used you can do reloading the grid.
In form edit you can set reloadAfterSubmit to true

@unle70
Copy link
Author

unle70 commented Nov 7, 2019

Hi Tony,
That's OK. I know you're a busy guy :)
In my case the reload takes around 20-30 seconds, so it's not possible to perform a reload for every single cell edit.
Maybe in a future version you could separate the code for setting attributes and for calculating group summary so that they could have their own function call and you could call them whenever needed.

Thanks,
Udi

@unle70 unle70 closed this as completed Nov 7, 2019
@tonytomov
Copy link
Owner

Hello Udi,

I checked the problem regarding cellattr and it is a bug. I will reopen the issue until the bug is fixed.

@tonytomov
Copy link
Owner

Hello Udi,
I have try to fix the problem with cellattr event. Can you please check if it is ok for you?
Thank you

@unle70
Copy link
Author

unle70 commented Nov 14, 2019

Hi Tony,

Well, Yes and No.
The attributes are indeed refreshed for the edited cell (didn't check other cells in the row).
But it created a new bug.
After the editing is complete (pressing ENTER) the "beforeSelectRow" and "onSelectRow" events stop triggering for that edited row. They still work fine for other rows. This means you cannot edit a row more than once :(

Thank you

@tonytomov
Copy link
Owner

Hello,

Thank you for the feedback
I can't reproduce the problem. Can you please prepare small demo which demostrates the problem?

Thank you.

@unle70
Copy link
Author

unle70 commented Nov 15, 2019

Hi Tony,

OK, I found the issue.
Actually it was my code which was preventing clicks on the editable fields (part of my application).
The reason my code was making this mistake is because the "cellattr" event parameters are behaving differently on a normal grid creation and after editing:

There's a parameter into the "cellattr" event which is called "rawObject". When the grid is first constructed this parameter holds all the fields of the row. But after the editing is done and the "cellattr" is triggered again, the rawObject only holds the edited fields, the id and an "oper" field. Looks like this is actually the object which is sent to the server upon save.

I'm wondering, is this the way it should be or is it a bug?

Thanks,
Udi

@tonytomov
Copy link
Owner

It is not a bug, but it is a way the methods work.

By example in inline editing we use setRowData method, where the thing happen.
This method does not have a rawObject since this rawObject is not available (this raw object should be xml node when data is xml or json object if data is json) - it is available only when the data is created - to overcome partially the problem we pass the data which is passed as parameter in setRowData - i.e the edited data.

One possible solution is to get the data from the row before to save the new one and merge it with the edited data, but this way we go to catch 22 - we can not get the row data (getRowData) when we are in editing mode - I hope you understand the problem.

The same logic is for setCell when we use cell editing.

One possible solution would be to pass all the needed data from within editing module, but I need to make some investigations.

If you have any idea, please let me know.

@unle70
Copy link
Author

unle70 commented Nov 15, 2019

Hi Tony,

OK, I see the problem here.
I found a workaround which solves my problem. Other users might use this idea too, but I'm not sure if you would like to make it standard and implement it into jqGrid.

What I'm doing is to use the "serializeRowData" event and then I add the original (before edit) rowData into the payload (a JSON encoded object with "originalData" name) that is sent to the server. Then this object becomes available for me inside the "cellattr" event and I can use it for my decisions on the attributes.

@tonytomov
Copy link
Owner

tonytomov commented Nov 18, 2019

Hello Udi,

I see that for inline and form editing the problem can be fixed. In these modules we have all the needed data (editable and not editable cell values) which can be passed to setRowData and hence the cellattr will have all the needed information. The only limitation will be if the datatype is xml - in this case the rawObject will be json object and not xml node. Actually this parameter is not correct put in the method. The correct way is to use the 5 parameter of this event which in all cases is json object.

The cell editing need some extra code to fix this problem.

I will try to fix the problem for inline and formedit today and for the cell editing to the end of week

@tonytomov
Copy link
Owner

Udi,

I have fixed the problem (I think). If you have time you can test it and let me know if it is working as expected.

@unle70
Copy link
Author

unle70 commented Nov 20, 2019

Hi Tony,

I don't see any difference. I still cannot see the other fields in the cellattr. I only see the edited fields.

@tonytomov
Copy link
Owner

Can you prepare a example, which demonstrate the problem and post it here or send me a link?

Thank you.

@unle70
Copy link
Author

unle70 commented Nov 20, 2019

Hi Tony,
I will try to prepare something.
In the meantime I found another problem with this. I told you about my workaround of adding the original data to the payload going out to the server (using serializeRowData). This was working fine, until I tried to implement the successfunc event. If I implement this event (even if I return [true, ''] as constant), the object I have added with the original row data is no longer being transferred to the cellattr.

@tonytomov
Copy link
Owner

Ok. Prepare and describe in detail where you expect this data. Note that all the data is added in setRowData (which executes at end when everything is fine) and not during any events in the editing module.

@tonytomov
Copy link
Owner

Hello Udi,

I will close the issue. If you will, please feel free to reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants