How can I change sScrollXInner after initialization

How can I change sScrollXInner after initialization

brobarbrobar Posts: 3Questions: 0Answers: 0
edited October 2013 in General
I am updating the number of columns in my table dynamically. I have a fixed left column and the rest are scrolling and I want the columns to each be a fixed 140 columns. I'm able to set the initial sScrollXInner and it works great, but after I dynamically update the number of columns with different data, I'm not sure how to update the sScrollXInner with the new width. Is there a way to update just that value without having to destroy and recreate the entire thing?

[code]
var modsTableCount = 0;
$('#dispModuleTableTBody tr:nth-child(1) th').each(function () { modsTableCount++; });

var modulesTable = $('#dispModuleTable').dataTable( {
"sScrollY": "100%",
"sScrollX": "100%",
"sScrollXInner": ((modsTableCount - 1) * 140),
"bScrollCollapse": false,
"bPaginate":false,
"bSort":false,
"bFilter":false,
"bAutoWidth":false,
"bInfo":false
} );
new FixedColumns( modulesTable, {
"iLeftWidth": 140
} );
[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    No - sorry. I'd say actually, sScrollXInner shouldn't be used at all. I made a mistake putting it in.

    Without it, DataTables will scroll as much as needed.

    Allan
  • brobarbrobar Posts: 3Questions: 0Answers: 0
    Is there some other way to tackle having each column be a specific width? I've tried CSS (both external and inline) and the width isn't applied. About the only way I could figure out how to get the columns to have basically the same width is applying the sScrollXInner value to number of columns (minus 1 because I don't want it to count the fixed left column) times the number of pixels I want each column to be.

    There might be an easier way though. If so... I would appreciate it if someone could enlighten me.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Column width in tables is a nightmare. Can you please link to your page so I can take a look and say what might be happening. It could be a number of things! For example the browser will always try to collapse the table to the minimum width, even if it means ignoring the width you set.

    Allan
  • brobarbrobar Posts: 3Questions: 0Answers: 0
    It is an internal app... I don't have it on any public servers. I did take your advice though and completely took sScrollXInner out. Since most of the data in each column is pretty close to the same size, I just add a little left and right padding to each column and it looks pretty decent. They aren't all EXACTLY 140 pixels... but it comes out pretty close... close enough for government work.
This discussion has been closed.