Subversion-Projekte lars-tiefland.cienc

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
9 lars 1
var EcommerceProducts = 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 handleProducts = function() {
12
        var grid = new Datatable();
13
 
14
        grid.init({
15
            src: $("#datatable_products"),
16
            onSuccess: function (grid) {
17
                // execute some code after table records loaded
18
            },
19
            onError: function (grid) {
20
                // execute some code on network or other general error
21
            },
22
            loadingMessage: 'Loading...',
23
            dataTable: { // here you can define a typical datatable settings from http://datatables.net/usage/options
24
 
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],
32
                    [10, 20, 50, 100, 150] // change per page values here
33
                ],
34
                "pageLength": 10, // default record count per page
35
                "ajax": {
36
                    "url": "../demo/ecommerce_products.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
                App.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
                App.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
    return {
75
 
76
        //main function to initiate the module
77
        init: function () {
78
 
79
            handleProducts();
80
            initPickers();
81
 
82
        }
83
 
84
    };
85
 
86
}();
87
 
88
jQuery(document).ready(function() {
89
   EcommerceProducts.init();
90
});