Subversion-Projekte lars-tiefland.cienc

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
9 lars 1
var EcommerceOrders = function () {
2
 
3
    var initPickers = function () {
4
        //init date pickers
5
        $('.date-picker').datepicker({
6
            rtl: App.isRTL(),
7
            autoclose: true
8
        });
9
    }
10
 
11
    var handleOrders = function () {
12
 
13
        var grid = new Datatable();
14
 
15
        grid.init({
16
            src: $("#datatable_orders"),
17
            onSuccess: function (grid) {
18
                // execute some code after table records loaded
19
            },
20
            onError: function (grid) {
21
                // execute some code on network or other general error
22
            },
23
            loadingMessage: 'Loading...',
24
            dataTable: { // here you can define a typical datatable settings from http://datatables.net/usage/options
25
                // Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
26
                // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/scripts/datatable.js).
27
                // So when dropdowns used the scrollable div should be removed.
28
                //"dom": "<'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'<'table-group-actions pull-right'>>r>t<'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>>",
29
 
30
                "lengthMenu": [
31
                    [10, 20, 50, 100, 150, -1],
32
                    [10, 20, 50, 100, 150, "All"] // change per page values here
33
                ],
34
                "pageLength": 10, // default record count per page
35
                "ajax": {
36
                    "url": "../demo/ecommerce_orders.php", // ajax source
37
                },
38
                "order": [
39
                    [1, "asc"]
40
                ] // set first column as a default sort by asc
41
            }
42
        });
43
 
44
        // handle group actionsubmit button click
45
        grid.getTableWrapper().on('click', '.table-group-action-submit', function (e) {
46
            e.preventDefault();
47
            var action = $(".table-group-action-input", grid.getTableWrapper());
48
            if (action.val() != "" && grid.getSelectedRowsCount() > 0) {
49
                grid.setAjaxParam("customActionType", "group_action");
50
                grid.setAjaxParam("customActionName", action.val());
51
                grid.setAjaxParam("id", grid.getSelectedRows());
52
                grid.getDataTable().ajax.reload();
53
                grid.clearAjaxParams();
54
            } else if (action.val() == "") {
55
                alert({
56
                    type: 'danger',
57
                    icon: 'warning',
58
                    message: 'Please select an action',
59
                    container: grid.getTableWrapper(),
60
                    place: 'prepend'
61
                });
62
            } else if (grid.getSelectedRowsCount() === 0) {
63
                alert({
64
                    type: 'danger',
65
                    icon: 'warning',
66
                    message: 'No record selected',
67
                    container: grid.getTableWrapper(),
68
                    place: 'prepend'
69
                });
70
            }
71
        });
72
 
73
    }
74
 
75
    return {
76
 
77
        //main function to initiate the module
78
        init: function () {
79
 
80
            initPickers();
81
            handleOrders();
82
        }
83
 
84
    };
85
 
86
}();
87
 
88
jQuery(document).ready(function() {
89
   EcommerceOrders.init();
90
});