Buy now!

NinjaGrid

Sample 06. Totalizing columns

HTML

                        

JS

                        var columnsModel = new Array();
                        columnsModel.push({ header: "ID", property: "id", width: 60, sort: true });
                        columnsModel.push({ header: "Name", property: "name", width: 200, sort: true,
                            totalize: {
                                align: "left",
                                type: "count",
                                format: function (vl, obj) {
                                    return vl + " clients";
                                }
                            }
                        });
                        columnsModel.push({ header: "Salary", property: "salary", width: 100, sort: true, align: "right", format: function (vl, obj) {
                                return applyNumberFormat(vl, 2, '.', ',', '$ ');
                            },
                            totalize: {
                                align: "right",
                                type: "sum",
                                format: function (vl, obj) {
                                    return applyNumberFormat(vl, 2, '.', ',', '$ ');
                                }
                            }
                        });
                        columnsModel.push({ header: "Birthday", property: "birthday", width: 100, sort: true, align: "center", format: "date" });
                        columnsModel.push({ header: "E-mail", property: "email", width: 250, sort: true });
                        columnsModel.push({ header: "Car Name", property: "car.name", width: 100, sort: true, align: "left" });
                        columnsModel.push({ header: "Car Year", property: "car.year", width: 100, sort: true, align: "right" });

                        $("#ninjaGridSample").ninjaGrid({
                            dataSource: source,
                            columns: columnsModel,
                            pageSize: 0,
                            sortColumn: "id",
                            sortOrder: "desc",
                            minHeight: 150
                        });