Pagination Fubars Post Response
Pagination Fubars Post Response
Allan,
Congrats on the newborn!!
When I select a product with a select2 plugin in Editor it posts correctly and receives the right data back from the server. When it's a single page table it updates the row correctly. When it's multi page it does not.
It seems that Editor kicks the draw() in before our submitSuccess()
starts/completes.
Is this a known bug or is it a result of how we're processing it? Here's the portion of our submitSuccess()
that is going awry:
.on("submitSuccess", function(e, json, data) {
var rowIds = json.ids;
// Update our originating row first and check pricing
var dataSort = 0,
offerId = $(".updating").parent("tr").closest("table.dataTable").data("offerid");
// If we have multiple rows to edit then let's get to it
_mpProjectedSpend = 0;
if (rowIds.length > 0) {
var dt = utility.getDt();
$.each(rowIds, function(i, el) {
var tr;
$("tr").each(function() {
if (this.id == el) {
tr = $(this);
}
});
var row = dt.row( tr )
var rowData = row.data();
// Set the row's data to match our returned json
rowData.offerItem = json.OfferVenIt;
rowData.offerDescription = json.OfferItDesc;
rowData.offerUom = json.OfferUOM;
rowData.offerConversion = json.OfferUOMConv;
rowData.offerPriceUom = parseFloat(json.OfferPricePerUOM).toFixed(2);
rowData.projectedSpend = utility.calculateProjectedSpend(rowData);
_mpProjectedSpend = rowData.projectedSpend
// Update it officially
row.data(rowData);
row.invalidate().draw();
Thanks for any insight!
This question has an accepted answers - jump to answer
Answers
Hi,
Could you clarify what you mean by it not working. What is happening and what did you expect to happen?
You are correct that the draw will occur before
submitSuccess
. You could usepostCreate
andpostEdit
if you want an event to occur before the draw, however, it looks like your function is changing the data that is returned from the server after Editor has already tried to use it. You could manipulate the data returned from the server usingpostSubmit
which is probably a better option.Allan
Hey Allan,
Sure. User selects a product from Select2, it sends the product ID to the server to grab all the relevant info, process how much quantity, price, etc. is applicable, and sends all that back which is what we then use to fill in the data. As you can see, the variables in the server side processing are named differently which is probably the primary reason we went this route (been a while so I can't remember w certainty) of having to manipulate it after submission.
There is the option to create a new product (pulls up the usual Editor modal data entry view) as well as select one already in existence. I'll give the
postSubmit
callback a try, may have to split the two types' (create v. select) callbacks. Should get a chance to check this out today, will post back once I do so.Thanks!
Thanks for the tip above, Allan. I tried
postSubmit()
with no luck.postEdit()
however did just fine. Thanks!Great to hear - thanks for posting back.
Allan