Converting to Server Side DataTable: Losing Column Type

Converting to Server Side DataTable: Losing Column Type

mju516mju516 Posts: 9Questions: 6Answers: 0

I'm experimenting with converting an existing DataTable to a Server Side one, but I'm running into a problem with a piece of external code that would iterate through the DataTable's columns, and fetch the column's type. An example:

$("#SomeDataTableID").DataTable().columns().every(function(){
   var columnType = this.context[0].aoColumns[0].sType;
})

When I was loading the DataTable with regular Json data, this code would return the column type that had been inferred, or that I had specified in the "columns" property of the DataTable initialization. However, after switching to Server Side processing, the "sType" property of each columns is NULL.

Is this to be expected? If so, is there another way that I can iterate through the columns and fetch the data type?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,482Questions: 1Answers: 10,467 Site admin
    Answer ✓

    The column type isn't relevant with server-side processing. It is used for client-side processing only.

    If the type is important at the server-side your server-side processing script would need to have knowledge of what the type is.

    Allan

  • mju516mju516 Posts: 9Questions: 6Answers: 0

    Ah okay. Yeah for my example, it was related to some client side code that I was doing based on specific data types. But it doesn't seem like there's a way to pull column types on the client side in this case.

This discussion has been closed.