Compatibility with 1.9 - _fnBuildAjax now converts Array to Object as $.ajax data member, BUT..
Compatibility with 1.9 - _fnBuildAjax now converts Array to Object as $.ajax data member, BUT..
Hi Allan,
first of all I must say you did a super job with this super tool alled DataTables! I love it, it has some drawbacks, but it is extensible to the max! Really cool work!
But I found an issue, when I was upgrading from 1.9.4 to 1.10.0-rc1. I have the following setup:
Use Ajax source and server-side processing to an ASP.NET WebApi Controller which returns JSON, based on the given model. The model contains several Enumarables.
On my web site I am having a "form" element which contains several "select multiple".."/select" elements. I have extended the aoData property which is handed through by fnServerParam by extending it in that way:
fnServerParams = function (aoData) {
var data = [];
if (bUseFormDataForAjaxData) {
data = $('#' + sAjaxDataFormId).serializeArray();
$.merge(aoData, data);
}
return aoData;
}
As a side note concerning compatibility to < 1.10.0: I had to change my "custom" fnServerParam function to return a value (i.e. aoData). In DT 1.9.4 I believe that the original passed "aoData" parameter was used. That was the reason why I $.merge(d) it :)
The problem is, that DT 1.10.0 now removes multiple entiries with the same Key from the Ajax Query Parameters..before that (DT 1.9.4) it wasn't removing these multiple elements. It was using an query string like: SelectedValue=1&SelectedValue=2&SelectedValue=3, etc. I need to pass additionally to the DT parameters the serialized form element.
As per Ajax API it tells for the usage of "data" property:
"
data
Type: PlainObject or String
Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below)."
And I would need this kind of "multiple values with same key" approach. How can I achive that which the current RC?
Thanks in advance Allan for any suggestion! :-)
I created an test case where you can see the issue at: http://live.datatables.net/vasixax/1/edit?html,js,console,output
BTW. DT is awesome!
Lukas
Answers
Hi,
ok I now realized how awesome DT1.10 is :) I will rewrite my code to use the new API.
Thanks Allan for your great work! If I'll have questions or can somehow contribute I'll post it here :)
Cheers,
Lukas
But as it looks like the problem will still remain! The conversion from the array to the object in line 2290 leads to the loss of data for the ajax call. :-( Seems there is no workaround for it.
Ok now I realized that you "fixed" this behavior on April 16th :-D Maybe you could make that behavior configurable? So I could override the default behavior when I'd need to pass multiple values with the same key as a parameter for SSP?
Cheers,
Lukas