WebFOCUS write back function using Datatables Editor
WebFOCUS write back function using Datatables Editor
Hi @Allan
As discussed a while back we integrate our datatable editor functionality with a reporting service called WebFOCUS which has some specific format requirements when defining variables to be passed between the browser client and the reporting server.
Key to this is a preSubmit function which flattens the variables being passed on submit. Example below:
function preSubmitFunction (e,d,a) {
for (p in d.data) {
d['ROW_ID'] = p ;
for (q in d.data[p]) {d[q] = d.data[p][q];}
}
delete d.data;
}
This method works well for an edit of a single row of data however if multiple rows are selected for edit; on submit only one row is sent for update naturally.
I have a solution in mind of creating a clone of the editor and having the preSubmit function each rows update information to the new editor and submit each in turn. This would then cancel the original multi row submit.
I was wondering if there was a better way to accomplish this. Would it be possible to update the editor code to add something like “editor.submit(d.data[p])” to the above function?
Replies
The best option would be to have the server-side accept a format that includes information for multiple rows. Is that possible?
The code above intentionally flattens the data so it is only ever possible to submit one row - really you need to not flatten the data and have the server accept arrays / objects.
Allan
Thanks @allan
I created a proof of concept that handles the data-set on the server-side and successfully updates the database and returns the required response. It's not particularly pretty but it is working.
I have some concerns that this would introduce some issues with users submitting exceptionally large amounts of data though. There is in theory no limit on the number of records this method can handle.
I'll have a play with my clone method idea and see if I can come up with a more elegant client-side solution.
Will try to share what I find.
So after a year of use we've not had any issues. I'll try to add the code we used below:
First we need to prep the array for sending to WebFOCUS
And the following is in WebFOCUS accessing the array
Super - thanks for sharing that with us!
Allan