created a new functionlity to update the sScrollXInner setting of the table

created a new functionlity to update the sScrollXInner setting of the table

bugreportbugreport Posts: 10Questions: 0Answers: 0
edited September 2011 in General
In some of my cases my table is to big fot the page thats why i use the sScrollXInner setting.
but when i hide some of the columns it can be usefull to recalculate the sScrollXInner and update these.

i would like to share this functionality

this.UpdateScrolXY = function ( width)
{
var oSettings = _fnSettingsFromNode(this[_oExt.iApiIndex]);
if(width != "")
{
oSettings.oScroll.sXInner= width;
}
this.fnDraw();
}

Replies

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    Thanks for that! This could be wrapped up into an API plug-in function to save modifying the code, while still providing all the same options. The way to do that is described here: http://datatables.net/blog/Creating_feature_plug-ins (API section).

    Allan
  • bugreportbugreport Posts: 10Questions: 0Answers: 0
    thanks just where i was looking for :)
  • Ironwil616Ironwil616 Posts: 50Questions: 0Answers: 0
    This share is appreciated, but since I have no idea where to put the code to make it work, it's not so useful to me. Is there a callback that fires when a column is hidden? I haven't found one yet, and that's about the only place I'd know to put this code.
  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    @Ironwil616 - bugreport's code would be put into the jquery.dataTables.js file - along with the other API methods that DataTables presents. Or if you follow the link I put in above you would see how it can be crafted into a plug-in method.

    Allan
  • bugreportbugreport Posts: 10Questions: 0Answers: 0
    use:
    $.fn.dataTableExt.oApi.UpdateScrolX = function (oSettings, width)
    {
    //var oSettings = _fnSettingsFromNode(this[_oExt.iApiIndex]);
    if(width != "")
    {
    oSettings.oScroll.sXInner= width;
    }
    this.fnDraw();
    }

    put this in a new file (for example datatablesExtentions.js) add this js page to you'r html after the datatables js file
This discussion has been closed.