Permalink
Browse files

Initial Commit

  • Loading branch information...
0 parents commit de82b0ac6d4e0508e5ffdf3caeb4f699b6b95a42 @tabalinas committed Oct 24, 2014
@@ -0,0 +1,2 @@
+dist
+node_modules
@@ -0,0 +1,43 @@
+module.exports = function(grunt) {
+ "use strict"
+
+ grunt.initConfig({
+ pkg: grunt.file.readJSON("package.json"),
+
+ concat: {
+ options: {
+ separator: "\n"
+ },
+ dist: {
+ src: [
+ "src/jsgrid.core.js",
+ "src/jsgrid.load-strategies.js",
+ "src/jsgrid.sort-strategies.js",
+ "src/jsgrid.field.js",
+ "src/jsgrid.field.text.js",
+ "src/jsgrid.field.textarea.js",
+ "src/jsgrid.field.select.js",
+ "src/jsgrid.field.checkbox.js",
+ "src/jsgrid.field.control.js"
+ ],
+ dest: "dist/<%= pkg.name %>.js"
+ }
+ },
+
+ uglify: {
+ options: {
+ banner: "/* <%= pkg.name %> <%= grunt.template.today(\"yyyy-mm-dd\") %> */"
+ },
+ build: {
+ src: "<%= concat.dist.dest %>",
+ dest: "dist/<%= pkg.name %>.min.js"
+ }
+ }
+
+ });
+
+ grunt.loadNpmTasks("grunt-contrib-concat");
+ grunt.loadNpmTasks("grunt-contrib-uglify");
+
+ grunt.registerTask("default", ["concat", "uglify"]);
+};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,210 @@
+.jsgrid {
+ font-size: 1em;
+ position: relative;
+ overflow: hidden;
+}
+
+.jsgrid-grid-header {
+}
+
+.jsgrid-grid-body {
+ overflow: hidden;
+ border: 1px solid #E2E2E2;
+ border-left: none;
+}
+
+.jsgrid-table {
+ table-layout: fixed;
+ border-collapse: collapse;
+}
+
+.jsgrid-table td {
+ padding: 0.3em 0.5em;
+ border: #F3F3F3 1px solid;
+}
+
+.jsgrid-align-left {
+ text-align: left;
+}
+
+.jsgrid-align-center {
+ text-align: center;
+}
+
+.jsgrid-align-right {
+ text-align: right;
+}
+
+.jsgrid-header-row {
+ background: #efefef;
+}
+
+.jsgrid-header-row th {
+ text-align: center;
+ padding: .5em .5em;
+ border: 1px solid #E2E2E2;
+ border-bottom: none;
+}
+
+.jsgrid-filter-row {
+}
+
+.jsgrid-filter-row td {
+ border: 1px solid #E2E2E2;
+ text-align: center;
+ background: #F9FCFC;
+}
+
+.jsgrid-filter-row input, .jsgrid-filter-row textarea, .jsgrid-filter-row select {
+ width: 90%;
+}
+
+.jsgrid-insert-row {
+}
+
+.jsgrid-insert-row td {
+ border: 1px solid #E2E2E2;
+ text-align: center;
+ background: #e0ffbf;
+}
+
+.jsgrid-insert-row input, .jsgrid-insert-row textarea, .jsgrid-insert-row select {
+ width: 90%;
+}
+
+.jsgrid-edit-row {
+}
+
+.jsgrid-edit-row td {
+ border: 1px solid #E2E2E2;
+ text-align: center;
+ background: #fcffc9;
+}
+
+.jsgrid-edit-row input, .jsgrid-edit-row textarea, .jsgrid-edit-row select {
+ width: 90%;
+}
+
+.jsgrid-row td {
+ background: #FFFFFF;
+}
+
+.jsgrid-alt-row td {
+ background: #F9FCFC;
+}
+
+.jsgrid-selected-row {
+}
+
+.jsgrid-selected-row td {
+ background: url(images/jsgrid-table_selrow_bg.gif) bottom left repeat-x #F7FCFD !important;
+ border-bottom: 1px solid #C0EBFE !important;
+ cursor: pointer;
+}
+
+.jsgrid-nodata-row td {
+ font-weight: bold;
+ padding: .5em 0;
+ text-align: center;
+ background: #FFFFFF;
+}
+
+.jsgrid-pager {
+ padding-top: .5em;
+}
+
+.jsgrid-pager-nav-button {
+ padding: .4em .4em 0 .4em;
+}
+
+.jsgrid-pager-page {
+ padding: .4em .4em 0 .4em;
+}
+
+.jsgrid-pager-current-page {
+ font-weight: bold;
+}
+
+.jsgrid-header-sort {
+ cursor: pointer;
+}
+
+.jsgrid-header-sort-asc {
+ background: url(images/jsgrid-table_th_sort_asc.png) 1em 1em no-repeat #d6eef3;
+}
+
+.jsgrid-header-sort-desc {
+ background: url(images/jsgrid-table_th_sort_desc.png) 1em 1em no-repeat #d6eef3;
+}
+
+.jsgrid-search-mode-button {
+ background: url(images/jsgrid-search_mode.png);
+ width: 24px;
+ height: 24px;
+ border: none;
+ cursor: pointer;
+}
+
+.jsgrid-insert-mode-button {
+ background: url(images/jsgrid-insert_mode.png);
+ width: 24px;
+ height: 24px;
+ border: none;
+ cursor: pointer;
+}
+
+.jsgrid-filter-row .jsgrid-search-button {
+ background: url(images/jsgrid-search.png);
+ width: 16px;
+ height: 16px;
+ border: none;
+ cursor: pointer;
+}
+
+.jsgrid-filter-row .jsgrid-clear-filter-button {
+ background: url(images/jsgrid-clear_filter.png);
+ width: 16px;
+ height: 16px;
+ border: none;
+ cursor: pointer;
+}
+
+.jsgrid-insert-row .jsgrid-insert-button {
+ background: url(images/jsgrid-insert.png);
+ width: 16px;
+ height: 16px;
+ border: none;
+ cursor: pointer;
+}
+
+.jsgrid-control-field .jsgrid-edit-button {
+ background: url(images/jsgrid-edit.png);
+ width: 16px;
+ height: 16px;
+ border: none;
+ cursor: pointer;
+}
+
+.jsgrid-control-field .jsgrid-delete-button {
+ background: url(images/jsgrid-delete.png);
+ width: 16px;
+ height: 16px;
+ border: none;
+ cursor: pointer;
+}
+
+.jsgrid-edit-row .jsgrid-update-button {
+ background: url(images/jsgrid-update.png);
+ width: 16px;
+ height: 16px;
+ border: none;
+ cursor: pointer;
+}
+
+.jsgrid-edit-row .jsgrid-cancel-edit-button {
+ background: url(images/jsgrid-cancel_edit.png);
+ width: 16px;
+ height: 16px;
+ border: none;
+ cursor: pointer;
+}
@@ -0,0 +1,128 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title></title>
+ <link rel="stylesheet" type="text/css" href="../css/jsgrid.css" />
+ <script src="../external/jquery/jquery-1.8.3.js"></script>
+ <script src="../dist/jsgrid.js"></script>
+
+ <style>
+ * {
+ margin: 0;
+ padding: 0;
+ }
+
+ html {
+ height: 100%;
+ }
+
+ body {
+ font-family: Tahoma;
+ font-size: 12px;
+ height: 100%;
+ }
+
+ .grid-container {
+ position: relative;
+ width: 100%;
+ height: 70%;
+ margin: 10px 0;
+ }
+ </style>
+</head>
+<body>
+ <div class="grid-container">
+ <div id="jsGrid"></div>
+ </div>
+
+ <script>
+ $(function() {
+ var data = [];
+ for(var i = 1; i <= 100; i++) {
+ data.push({
+ Name: "Client" + i,
+ Age: 20 + i,
+ Address: "St. Moscow " + i,
+ Married: false,
+ Country: i % 3 + 1
+ });
+ }
+
+ var gridController = {
+ loadData: function(filter) {
+ var filteredData = $.grep(data, function(item) {
+ var found = true;
+ $.each(filter, function(key, value) {
+ if(value != "" && value != "0" && item.hasOwnProperty(key) && item[key] != value) {
+ found = false;
+ return false;
+ }
+ });
+ return found;
+ });
+
+ if(filter.pageIndex !== undefined) {
+ var startIndex = (filter.pageIndex - 1) * filter.pageSize;
+ result = {
+ data: filteredData.slice(startIndex, startIndex + filter.pageSize),
+ itemsCount: filteredData.length
+ };
+ }
+ else {
+ result = filteredData;
+ }
+
+ return result;
+ },
+ insertItem: function(insertingItem) {
+ data.push(insertingItem);
+ return insertingItem;
+ },
+ updateItem: function(updatingItem) {
+ updatingItem["Country"] = parseInt(updatingItem["Country"]);
+ return updatingItem;
+ },
+ deleteItem: function(deletingItem) {
+ data.splice($.inArray(deletingItem, data), 1);
+ return deletingItem;
+ }
+ };
+
+ $("#jsGrid").jsGrid({
+ height: "70%",
+ width: "50%",
+ scrollbar: true,
+ filtering: true,
+ editing: true,
+ pageLoading: false,
+ sorting: true,
+ paging: true,
+ autoload: true,
+ pageSize: 10,
+ pageButtonCount: 5,
+ controller: gridController,
+ fields: [
+ new jsGrid.TextField("Name", { title: "Name" }),
+ new jsGrid.TextField("Age", { title: "Age", sorter: "Number", align: "right" }),
+ new jsGrid.TextField("Address", { title: "Address" }),
+ new jsGrid.CheckboxField("Married", { title: "Married" }),
+ new jsGrid.SelectField("Country", {
+ title: "Country",
+ items: [
+ { text: "(Select)", value: 0 },
+ { text: "Russia", value: 1 },
+ { text: "USA", value: 2 },
+ { text: "England", value: 3 }
+ ],
+ textField: "text",
+ valueField: "value"
+ }),
+ new jsGrid.ControlField({
+ editButton: false
+ })
+ ]
+ });
+ });
+ </script>
+</body>
+</html>
Oops, something went wrong.

0 comments on commit de82b0a

Please sign in to comment.