Skip to content

Commit da6bcf9

Browse files
committed
fix code formating
1 parent bf246a0 commit da6bcf9

File tree

3 files changed

+42
-28
lines changed

3 files changed

+42
-28
lines changed

src/js/core.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export function EventHandler() {
162162
handlers = [];
163163

164164
return this; // allow chaining
165-
}
165+
};
166166
}
167167

168168
/***
@@ -209,7 +209,7 @@ export function Range(fromRow, fromCell, toRow, toCell) {
209209
* @method isSingleRow
210210
* @return {Boolean}
211211
*/
212-
this.isSingleRow = function () {
212+
this.isSingleRow = function() {
213213
return this.fromRow == this.toRow;
214214
};
215215

@@ -229,7 +229,7 @@ export function Range(fromRow, fromCell, toRow, toCell) {
229229
* @param cell {Integer}
230230
* @return {Boolean}
231231
*/
232-
this.contains = function (row, cell) {
232+
this.contains = function(row, cell) {
233233
return row >= this.fromRow && row <= this.toRow &&
234234
cell >= this.fromCell && cell <= this.toCell;
235235
};
@@ -239,14 +239,14 @@ export function Range(fromRow, fromCell, toRow, toCell) {
239239
* @method toString
240240
* @return {String}
241241
*/
242-
this.toString = function () {
242+
this.toString = function() {
243243
if (this.isSingleCell()) {
244244
return "(" + this.fromRow + ":" + this.fromCell + ")";
245245
}
246246
else {
247247
return "(" + this.fromRow + ":" + this.fromCell + " - " + this.toRow + ":" + this.toCell + ")";
248248
}
249-
}
249+
};
250250
}
251251

252252

src/js/grid.js

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,29 @@
33

44
// make sure required JavaScript modules are loaded
55
if (typeof jQuery === "undefined") {
6-
throw "Grid requires jquery module to be loaded";
6+
throw "GridView requires jquery to be loaded.";
77
}
88
if (!jQuery.fn.drag) {
9-
throw "Grid requires jquery.event.drag module to be loaded";
9+
throw "GridView requires jquery.event.drag to be loaded.";
1010
}
1111
if (typeof Slick === "undefined") {
12-
throw "slick.core.js not loaded";
12+
throw "GridView core is not loaded.";
1313
}
1414

1515

1616
// shared across all grids on the page
1717
var scrollbarDimensions;
1818
var maxSupportedCssHeight; // browser's breaking point
1919

20-
//////////////////////////////////////////////////////////////////////////////////////////////
21-
// Grid class implementation (available as Slick.Grid)
20+
// GridView class implementation (available as Slick.GridView)
2221

2322
/**
2423
* Creates a new instance of the grid.
25-
* @class Grid
24+
* @class GridView
2625
* @constructor
27-
* @param {Node} container Container node to create the grid in.
28-
* @param {Array,Object} data An array of objects for databinding.
29-
* @param {Array} columns An array of column definitions.
30-
* @param {Object} options Grid options.
26+
* @param {Object} options GridView options.
3127
**/
32-
function Grid(container, data, columns, options) {
28+
function GridView(container, data, columns, options) {
3329
// settings
3430
var defaults = {
3531
explicitInitialization: false,
@@ -178,13 +174,10 @@ function Grid(container, data, columns, options) {
178174
var $hiddenParents;
179175
var oldProps = [];
180176

181-
//////////////////////////////////////////////////////////////////////////////////////////////
182-
// Initialization
183-
184177
function init() {
185178
$container = $(container);
186179
if ($container.length < 1) {
187-
throw new Error("Grid requires a valid container, " + container + " does not exist in the DOM.");
180+
throw new Error("GridView requires a valid container, " + container + " does not exist in the DOM.");
188181
}
189182

190183
cacheCssForHiddenInit();
@@ -211,7 +204,7 @@ function Grid(container, data, columns, options) {
211204

212205
// validate loaded JavaScript modules against requested options
213206
if (options.enableColumnReorder && !$.fn.sortable) {
214-
throw new Error("Grid's 'enableColumnReorder = true' option requires jquery-ui.sortable module to be loaded");
207+
throw new Error("GridView's 'enableColumnReorder = true' option requires jquery-ui.sortable module to be loaded");
215208
}
216209

217210
editController = {
@@ -288,7 +281,7 @@ function Grid(container, data, columns, options) {
288281
// calculate the diff so we can set consistent sizes
289282
measureCellPaddingAndBorder();
290283

291-
// for usability reasons, all text selection in Grid is disabled
284+
// for usability reasons, all text selection in GridView is disabled
292285
// with the exception of input and textarea elements (selection must
293286
// be enabled there so that editors work as expected); note that
294287
// selection in grid cells (grid body) is already unavailable in
@@ -460,7 +453,7 @@ function Grid(container, data, columns, options) {
460453
var w=canvasWidth + (viewportHasVScroll ? scrollbarDimensions.width : 0);
461454
$headerRowSpacer.width(w);
462455
if (options.createFooterRow) { $footerRowSpacer.width(w); }
463-
if (canvasWidth != oldCanvasWidth || forceColumnWidthsUpdate) { applyColumnWidths();
456+
if (canvasWidth != oldCanvasWidth || forceColumnWidthsUpdate) { applyColumnWidths();
464457
}
465458
}
466459

@@ -2829,7 +2822,7 @@ function makeActiveCellEditable(editor) {
28292822
return;
28302823
}
28312824
if (!options.editable) {
2832-
throw "Grid : makeActiveCellEditable : should never get called when options.editable is false";
2825+
throw "GridView : makeActiveCellEditable : should never get called when options.editable is false";
28332826
}
28342827

28352828
// cancel pending async call if there is one
@@ -2941,7 +2934,7 @@ function getActiveCellPosition() {
29412934
return absBox(activeCellNode);
29422935
}
29432936

2944-
function getGridPosition() {
2937+
function getGridViewPosition() {
29452938
return absBox($container[0])
29462939
}
29472940

@@ -3551,7 +3544,7 @@ this.eval = function (expr) {
35513544
// Public API
35523545

35533546
$.extend(this, {
3554-
"slickGridVersion": "2.3.3",
3547+
"slickGridViewVersion": "2.3.3",
35553548

35563549
// Events
35573550
"onScroll": new Slick.Event(),
@@ -3661,7 +3654,7 @@ $.extend(this, {
36613654
"setFooterRowVisibility": setFooterRowVisibility,
36623655
"getFooterRow": getFooterRow,
36633656
"getFooterRowColumn": getFooterRowColumn,
3664-
"getGridPosition": getGridPosition,
3657+
"getGridViewPosition": getGridViewPosition,
36653658
"flashCell": flashCell,
36663659
"addCellCssStyles": addCellCssStyles,
36673660
"setCellCssStyles": setCellCssStyles,
@@ -3679,5 +3672,5 @@ $.extend(this, {
36793672
init();
36803673
}
36813674

3682-
export default Grid;
3675+
export default GridView;
36833676

src/js/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,26 @@ export function createAjaxGrid() {
5353
5454
grid.onViewportChanged.notify();
5555
*/
56+
57+
var provider = new DataProvider({
58+
url: 'http://192.168.60.167:3002/api.php',
59+
pagination: {
60+
pageSize: 10,
61+
maxLimit: 500,
62+
}
63+
});
64+
65+
new GridView({
66+
el: $(".gridview"),
67+
dataProvider: provider,
68+
height: 550,
69+
groupable: true,
70+
sortable: true,
71+
pageable: {
72+
},
73+
columns: [
74+
]
75+
});
76+
5677
}
5778

0 commit comments

Comments
 (0)