DataTables 1.10 - Change needed ?

DataTables 1.10 - Change needed ?

AleksAleks Posts: 8Questions: 0Answers: 0
edited February 2014 in General
Hi there,

Thank you for the great job you did with DataTables 1.10 ! It is now really easier to use and to understand.

I have a question regarding data sent to the server when using server side processing. You included in the url "[" and "]" characters that break the simplicity of serializing and deserializing parameters.
I'm using .NET to treat those requests and such characters are not allowed in variable names.

Why did you do that and do you think it could be possible to rollback this ?

Thank you.
Aleks

Replies

  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    edited February 2014
    You can use the property `$.fn.dataTable.ext.legacy.ajax` and set it to true before you initialise your table to have DataTables use the old 1.9 style.

    Can .NET really not use url encoded array syntax?!

    It is done that way because most scripting languages will automatically parse such information into arrays - which that data is, so it makes sense to have it as such.

    Allan
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    Looks like you might be able to add `traditional: true` to the Ajax request to have .NET deal with it as an array: http://growingtech.blogspot.co.uk/2012/02/posting-array-or-generic-list-of-string.html .

    Allan
  • AleksAleks Posts: 8Questions: 0Answers: 0
    Hi Allan,

    The problem is not the array. "myarray=[1,2,3]" can be parsed by .NET.
    But "column[0].something" is not possible by default because .NET will try to match with a class property and "[" is not allowed in variable name.

    I was able to make it work with http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datamemberattribute.name(v=vs.110).aspx

    My feedback was just about the fact it don't seems natural to have those strings :)

    Thank you !
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    The problem is the array - the way jQuery created the HTTP variables is something like:

    [code]
    var myArray = [ 1, 2, 3 ];
    [/code]

    when submitted gives you:

    [code]
    myArray[] = 1;
    myArray[] = 2;
    myArray[] = 3;
    [/code]

    Most scripting languages will parse that as an array at the server, but the jQuery `traditional` Ajax option I believe is provided to provide a different way of serialising the data, presumably for .NET.

    Allan
This discussion has been closed.