Type detection in table header

Type detection in table header

pallsonypallsony Posts: 1Questions: 0Answers: 0
edited October 2011 in General
Hello all,

I'm trying to develop a complex application that will require dozens of reports with multiple types of data and formats. I'm not great with jQuery and so I was wondering if there was a way that instead of declaring the data types and formats in the head section like so:

[code]
oTable = $('#datatable').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aoColumns": [{ "sType": "custom_date" },null,null,null,null]
});
[/code]

I could just write the type in the table header. Something like this example:

[code]


Date
Category
Subcategory
Explanation
Value


[/code]

It would be very useful because there are dozens of tables and they would require dozens of initializations. Also the structure of the tables might be changed and updated often. If something like this can't be done is there a simple way of using custom data types for multiple tables that have different structures?

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    I've been meaning to create a plug-in for DataTables for years which does basically this kind of thing - but have never found the time to do it. It is a good idea and potentially very useful. Basically all that is needed is to get the TH elements and run a 'for' loop over them to get the properties that you want and build up aoColumns as required. I don't have a code example of doing that, but I suspect it shouldn't be more that that simple loop for a single property.

    Allan
This discussion has been closed.