Pass new POST parameter with another table data
Pass new POST parameter with another table data
I have two tables, one that has inventory items and another one with order items.
The inventory table works server side. It all works fine, I can add rows from inventory to order table.
The problem is that the inventory always gets all products, when it should exclude the ones in the order.
I need to pass to the server the order's table product ids so in this way I can remove them from inventory to avoid picking them up again.
This is what I've tried just to check I can access the order table and pass it to the MVC controller
$(target).DataTable({
"proccessing": true,
"serverSide": true,
"ajax": {
url: "@Url.Action("CustomServerSideSearchAction", "Inventory")",
type: 'POST',
data: {
CustomData: $('#OrderTable').DataTable().rows().count()
}
},
Data returned is always 0 even though the orders table contains more than one row.
Thank you
This question has an accepted answers - jump to answer
Answers
CustomData: $('#OrderTable').column(0).data();
Yes, because:
is evaluated only once - when the table is initialised. Consider that the row count is zero at that point, so actually it is the same as doing:
What you need is for the row count to be evaluated each time there is an ajax submission - that can be done by giving
ajax.data
as a function:Allan
Excellent !
It worked !
Thank you very much