Need help with sWrapper

Need help with sWrapper

MikeSMikeS Posts: 113Questions: 1Answers: 0
edited June 2010 in General
I'm trying to set the sWrapper to my own class for styling. I'm using the following (with version 1.7 beta 3):

$(document).ready( function() {
oTable=$('myTable').dataTable({
"sDom": '<"top">ifrt'
,"sWrapper": 'myDtWrapper'
,"bProcessing": true ...


It does not work for me. The default wrapper and my datatable wrapper are defined as:

.dataTables_wrapper {
position: relative;
height: 290px;
clear: both;
overflow-y: auto;
background: white;
}

.myDtWrapper {
position: relative;
height: 100%;
border: 0px;
}

The table always displays with a height of 290px when I'm expecting it to be 100% (i.e., much higher). Is there something obvious that I'm doing wrong here?

Replies

  • allanallan Posts: 62,029Questions: 1Answers: 10,168 Site admin
    Hi MikeS,

    sWrapper cannot be set as an initialisation parameter: http://datatables.net/styling/custom_classes

    [code]
    $.fn.dataTableExt.oStdClasses.sWrapper = "whatever";
    [/code]
    Allan
  • MikeSMikeS Posts: 113Questions: 1Answers: 0
    Thanks for the reply Allan.

    How do I use $.fn.dataTableExt.oStdClasses.sWrapper? I can see that I need to set it to my wrapper class, but, where do I do this?

    I'm a noob at jQuery and not too good at reading documentation. I still don't get it and without actual code examples I'm pretty much stuck. Sorry for being so dense.
  • allanallan Posts: 62,029Questions: 1Answers: 10,168 Site admin
    It's just a variable:

    [code]
    $.fn.dataTableExt.oStdClasses.sWrapper = "myDtWrapper";
    $('#example').dataTable();
    [/code]
    You set it before you initialise the table, and any of the other default classes you want to customise as well.

    Regards,
    Allan
  • smittlessmittles Posts: 13Questions: 0Answers: 0
    What if there are multiple tables on a page? How can I differentiate between them?
    [code]$.fn.dataTableExt.oJUIClasses.sWrapper = "myDtWrapper"; [/code]
    doesn't confine itself to a particular table, does it?
  • smittlessmittles Posts: 13Questions: 0Answers: 0
    I've answered my own question.

    [code]$.fn.dataTableExt.oJUIClasses.sWrapper = "myDtWrapper"; [/code]
    may be declared before each datatable initializer, and will affect tables after it. So,
    [code]
    //table1 needs class 'table1'
    $.fn.dataTableExt.oJUIClasses.sWrapper = "table1";
    $('#table-1').dataTable();
    [/code]
    and the wrapper will inherit the class 'table1' into '#table-2' by default, unless ...

    [code]
    //table2 needs class 'table2'
    $.fn.dataTableExt.oJUIClasses.sWrapper = "table2";
    $('#table-2').dataTable();
    [/code]
This discussion has been closed.