Making the datatable 508 compliant
Making the datatable 508 compliant
JohnJJordan
Posts: 14Questions: 0Answers: 0
I am trying to get my table to output the body with the first column as a for 508 compliancy. I have set up my table as shown below. I looked at the examples on this site, and I cannot find a definitive way to make it create the for the first column in each row. What do I need to do to make this work.
Title
State
Health Topic
Policy Topic
Type
Setting
Status
Year
Title
State
Health Topic
Policy Topic
Type
Setting
Status
Year
This discussion has been closed.
Replies
If you are creating your table from the DOM, then you are already doing everything you need to do! DataTables will keep the scope attribute you set on the TH cells. I've got an example of using the scope like that here: http://datatables.net/blog/Creating_beautiful_and_functional_tables_with_DataTables .
If however you are creating the table and the rows dynamically, then you'll need to use a little bit of Javascript to add the required property as DataTables doesn't have a built in method to do it. Using 1.9:
[code]
oTable.$('th').attr('scope', 'row');
[/code]
is all that is needed, where oTable is the DataTables instant for your table.
Regards.
Allan
Sorry form my deplayed response. I got pulled off to other tasks for a while and I just coming back to this issue.
I am using the data structure as mentioned above, however my table is not putting ... Instead I am getting a Here is my initialization code. I am just not seeing that I am doing anything wrong. Key points may be that I am doing server side processsing. Not sure if that matters or not.,..
function InitializeDataTables() {
// the datatable, see datatables.net for API
oTable = $('#output').dataTable({
"bProcessing": true,
"bFilter": false,
"bServerSide": true,
"bDeferRender": true,
"bAutoWidth": false,
"sDom": '<"top"lp<"clear">>rt<"bottom"ip<"clear">>',
"aLengthMenu": [[25, 50, 100], [25, 50, 100]],
"iDisplayLength": 25,
"sAjaxSource": "service.svc/GetPolicies",
"sAjaxDataProp": "Results.Policies",
"bPaginate": true,
"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
if (!aData['hasRelatedPolicies']) {
$(nRow).find('#flag').hide();
}
return nRow;
},
"fnDrawCallback": function(oSettings) { fnInitFacets($.parseJSON(oSettings.jqXHR.responseText)); },
"fnServerParams": function(aoData) {
var value = GetSelectedValues();
aoData.push({ "name": "facets", "value": value });
},
"sPaginationType": "full_numbers",
"aaSorting": [[8, 'desc']],
"aoColumns": [
{
"mDataProp": null,
"sClass": "control center",
"sDefaultContent": ''
},
{ "mDataProp": "Title" },
{ "mDataProp": "State" },
{ "mDataProp": "HealthTopic" },
{ "mDataProp": "PolicyTopic" },
{ "mDataProp": "Type" },
{ "mDataProp": "Setting" },
{
"bSortable": false,
"mDataProp": null,
"sClass": "relatedflag",
"sDefaultContent": ''
},
{ "mDataProp": "Status" },
{ "mDataProp": "Year" },
{ "mDataProp": "hasPolicyElements", "bVisible": false },
{ "mDataProp": "hasRelatedPolicies", "bVisible": false },
{ "mDataProp": "Abstract", "bVisible": false },
{ "mDataProp": "ID", "bVisible": false }
]
});
I would appreciate if you could offer me some insight as to what I may be doing wrong. I do not know of a way to change the first column from a td to a th.
Thanks
John
> I do not know of a way to change the first column from a td to a th.
I'm afraid that DataTables currently does not have an option for this. However it is certainly a good idea to allow columns to be created with TH elements rather than TD - I've made a note to add this for the next version as a column option. Great suggestion - thanks!
Regards,
Allan
Regards,
Allan
I am assuming that what you mean that every cell in the column would be effected means that every row's first column would be a . This is what I would expect. If you meant something else then please clarify
> I am assuming that what you mean that every cell in the column would be effected means that every row's first column would be a .
That's exactly it! :-)
Regards,
Allan
Regards,
Allan
Thanks for getting this added. It is very timely indeed. I will be sending some more support money your way shortly. I am waiting to get some money from my customer. I have a quick question related to the scope="row" attribute. do I have to add that through some script or is there another option I need to add to make this work.
[code]
var table = $('#example').dataTable{ {
"sAjaxSource": "ajax",
"aoColumnDefs": [
{
"aTargets": [0],
"sCellType": "th",
"fnCreatedCell": function ( cell ) {
cell.scope = 'row';
}
}
]
} );
[/code]
That initialises the table to use a TH in the first column and adds a scope attribute when the cell is created. Another option would be to use something like
[code]
table.$('th').attr('scope', 'row');
[/code]
once the table has initialised.
Allan