Quantcast
Viewing all articles
Browse latest Browse all 82141

aoColumns When number of columns vary

I have a page which will have a different number of columns, depending on the access rights of the user. There will either be 6 or 4 columns in the table. If there are 6, then this initialisation works fine.
	jQuery(document).ready(function() {
		oTable = jQuery('#rate').dataTable( {			// Initialise the Open Quote Table
				"sScrollY": "540px",					// Set scrollable area to 300 pixels
				"bScrollCollapse": true,				// Shrink the table if only a few rows displayed
				"bPaginate": false,						// Turn off pagination furniture (turning it on breaks Scrolling)
				"bAutoWidth": true,						// Let Datatable manage the column widths
				"bSort": true,							// Turn on Sorting for all columna
				"bInfo": false,							// Turn off "Showing x to y of nn entries" element
				"aaSorting": [[ 0, "desc" ]],			// By default, sort by Quote No. Descending
				"oLanguage": {"sEmptyTable": "No Sales Activities found for selected year.",		// Change the empty table text
							  "sSearch": "Search:"},	// Change Text for Filter box
				"aoColumns": [
					null,
      				{ "bSortable": false },
      				{ "bSortable": false },
      				{ "bSortable": false },
      				{ "bSortable": false },
      				{ "bSortable": false }
    				]
		} );
However, if I am only displaying 4 columns, it obviously breaks the table.

I gather from trolling through the discussions, that the number of columns can be retrieved from

oSettings.aoColumns.length

but I don't know if, or how, I can make use of that to adjust the initialisation depending on how many columns I am displaying. If this is possible, how should I alter the initialisation? I am by no means a jQuery or Javascript expert, so you may have to use words of one syllable for me to understand. Thanks.

Ron

Viewing all articles
Browse latest Browse all 82141

Trending Articles