Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference a column by id or class name #237

Open
Mottie opened this issue Feb 12, 2013 · 1 comment
Open

Reference a column by id or class name #237

Mottie opened this issue Feb 12, 2013 · 1 comment

Comments

@Mottie
Copy link
Owner

Mottie commented Feb 12, 2013

In the future, I was planning on making tablesorter work better with adding and removing columns dynamically. In order to do this, columns should instead be referenced by an id or class name. Here are some examples:

<table class="tablesorter-blue">
    <thead>
        <tr>
            <th class="col-acct">Account #</th>
            <th class="col-last">Last</th>
            <th class="col-first">First</th>
            <th class="col-date" id="date">Date</th>
        </tr>
    </thead>
    ...
</table>

Then when referencing a column, do it as follows:

// sort option
sortList : [[ ".col-last", "asc" ]]

// headers option
headers : {
    ".col-acct" : { sorter: "digit" },
    "#date"     : { sorter: "shortDate", dateFormat: "ddmmyyyy" }
}

// text extraction
textExtraction: {
    ".col-acct" : function(node, table, cellIndex) {
        return $(node).find("span:last").text();
    }
}

// filter functions
widgetOptions: {
    filter_functions : {
        ".col-date" : {
            "< 2004": function (e, n, f, i) {
                return n < Date.UTC(2004, 0, 1); // < Jan 1 2004
            },
            ...
        }
    }
}

Idea from answering this question on stackoverflow.

@Mottie Mottie mentioned this issue Mar 11, 2013
22 tasks
@TheSin-
Copy link
Collaborator

TheSin- commented Apr 24, 2014

awesome idea! This is why you are da man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants