~dongpo-deng/sahana-eden/test

« back to all changes in this revision

Viewing changes to views/dataTables.html

  • Committer: Deng Dongpo
  • Date: 2010-08-01 09:29:44 UTC
  • Revision ID: dongpo@dhcp-21193.iis.sinica.edu.tw-20100801092944-8t9obt4xtl7otesb
initial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{{if session.s3.debug:}}
 
2
 <script src="/{{=request.application}}/static/scripts/S3/jquery.dataTables.fixed.js" type="text/javascript" charset="utf-8"></script>
 
3
{{else:}}
 
4
 <script src="/{{=request.application}}/static/scripts/S3/jquery.dataTables.fixed.min.js" type="text/javascript" charset="utf-8"></script>
 
5
{{pass}}
 
6
<script type="text/javascript">//<![CDATA[
 
7
$(document).ready(function() {
 
8
    //Create an array for the column settings (this is required, otherwise the column widths don't autosize)a
 
9
    var myList = document.getElementById('list');
 
10
    if (myList!=null) {
 
11
        var ColumnCount = myList.getElementsByTagName('th').length;
 
12
    } else {
 
13
        var ColumnCount = 0;
 
14
    }
 
15
    var ColumnSettings = new Array();
 
16
    ColumnSettings[0] = { "sTitle": " ", "bSortable": false  }
 
17
    // buffer the array so that the default settings are preserved for the rest of the columns
 
18
    for (i=1; i<ColumnCount; i++)
 
19
        {
 
20
        ColumnSettings[i] = null;
 
21
        }
 
22
    $('#list').dataTable({
 
23
    {{try:}}
 
24
        {{if sortby:}}
 
25
            {"aaSorting": {{=XML(sortby)}}},
 
26
        {{else:}}
 
27
        {{pass}}
 
28
    {{except:}}
 
29
    {{pass}}
 
30
    {{if response.s3.pagination:}}
 
31
            // Disable Dynamic Search (until support for this fixed)
 
32
            "bFilter": true,
 
33
            // Disable Dynamic Sorting (until support for this fixed - works by value not representation)
 
34
            "bSort": true,
 
35
            "sPaginationType": "full_numbers",
 
36
            "iDisplayLength": 10,
 
37
            "bProcessing": true,
 
38
            "bServerSide": true,
 
39
            "sAjaxSource": "{{=jr.there(representation='aaData')}}",
 
40
    {{pass}}
 
41
    {{if response.s3.actions:}}
 
42
        "aoColumns": ColumnSettings,
 
43
        // Set the action buttons in the id (first) column for each row
 
44
        "fnRowCallback": function( nRow, aData, iDisplayIndex )
 
45
            {
 
46
            Actions = {{=XML(response.s3.actions)}};
 
47
            Buttons = '';
 
48
            // loop through each action to build the button
 
49
            for (i=0;i<Actions.length;i++)
 
50
                {
 
51
                // Extract the id # from the link
 
52
                var re = />(.*)</i;
 
53
                id = re.exec(aData[0])[1];
 
54
                c = Actions[i]._class
 
55
                re = /%5Bid%5D/g;
 
56
                Buttons = Buttons + '<a class="'+ c +'" href="' + Actions[i].url.replace(re,id) + '">' + Actions[i].label + '</a>' + '&nbsp;';
 
57
                }
 
58
            // Set the first column to the action buttons
 
59
            $('td:eq(0)', nRow).html( Buttons );
 
60
            return nRow;
 
61
            }
 
62
    {{pass}}
 
63
    });
 
64
});
 
65
//]]></script>