|
| 1 | +<!DOCTYPE HTML> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| 5 | + <link rel="shortcut icon" type="image/ico" href="favicon.ico" /> |
| 6 | + <title>SlickGrid example 1: Basic grid</title> |
| 7 | + <link rel="stylesheet" href="../slick.grid.css" type="text/css"/> |
| 8 | + <link rel="stylesheet" href="../css/smoothness/jquery-ui.css" type="text/css"/> |
| 9 | + <link rel="stylesheet" href="examples.css" type="text/css"/> |
| 10 | +</head> |
| 11 | +<body> |
| 12 | +<table width="100%"> |
| 13 | + <tr> |
| 14 | + <td valign="top" width="50%"> |
| 15 | + <div id="myGrid" style="width:600px;height:500px;"></div> |
| 16 | + </td> |
| 17 | + <td valign="top"> |
| 18 | + <h2>Demonstrates:</h2> |
| 19 | + <ul> |
| 20 | + <li>basic grid with minimal configuration</li> |
| 21 | + </ul> |
| 22 | + <button id="btnHideShow">Hide</button> |
| 23 | + |
| 24 | + <h2>View Source:</h2> |
| 25 | + <ul> |
| 26 | + <li><A href="https://github.com/6pac/SlickGrid/blob/master/examples/example1-simple.html" target="_sourcewindow"> View the source for this example on Github</a></li> |
| 27 | + </ul> |
| 28 | + </td> |
| 29 | + </tr> |
| 30 | +</table> |
| 31 | + |
| 32 | +<script src="../lib/jquery-1.12.4.min.js"></script> |
| 33 | +<script src="../lib/jquery.event.drag-2.3.0.js"></script> |
| 34 | + |
| 35 | +<script src="../slick.core.js"></script> |
| 36 | +<script src="../slick.grid.js"></script> |
| 37 | +<script src="../plugins/slick.cellrangedecorator.js"></script> |
| 38 | +<script src="../plugins/slick.cellrangeselector.js"></script> |
| 39 | +<script src="../plugins/slick.cellselectionmodel.js"></script> |
| 40 | + |
| 41 | +<script> |
| 42 | + var grid; |
| 43 | + var columns = [ |
| 44 | + {id: "title", name: "Title", field: "title"}, |
| 45 | + {id: "duration", name: "Duration", field: "duration"}, |
| 46 | + {id: "%", name: "% Complete", field: "percentComplete"}, |
| 47 | + {id: "start", name: "Start", field: "start"}, |
| 48 | + {id: "finish", name: "Finish", field: "finish"}, |
| 49 | + {id: "effort-driven", name: "Effort Driven", field: "effortDriven"} |
| 50 | + ]; |
| 51 | + |
| 52 | + var options = { |
| 53 | + enableCellNavigation: true, |
| 54 | + enableColumnReorder: false |
| 55 | + }; |
| 56 | + |
| 57 | + var showCol = true; |
| 58 | + |
| 59 | + $(function () { |
| 60 | + var data = []; |
| 61 | + for (var i = 0; i < 500; i++) { |
| 62 | + data[i] = { |
| 63 | + title: "Task " + i, |
| 64 | + duration: "5 days", |
| 65 | + percentComplete: Math.round(Math.random() * 100), |
| 66 | + start: "01/01/2009", |
| 67 | + finish: "01/05/2009", |
| 68 | + effortDriven: (i % 5 == 0) |
| 69 | + }; |
| 70 | + } |
| 71 | + |
| 72 | + grid = new Slick.Grid("#myGrid", data, columns, options); |
| 73 | + grid.setSelectionModel(new Slick.CellSelectionModel()); |
| 74 | + |
| 75 | + $("#btnHideShow").click(function () { |
| 76 | + showCol= !showCol; |
| 77 | + var showColArr = (showCol ? columns : columns.filter(function(x){ return x.id != "duration"; } )) |
| 78 | + grid.setColumns(showColArr); |
| 79 | + |
| 80 | + //grid.getSelectionModel().refreshSelections(); |
| 81 | + }); |
| 82 | + }) |
| 83 | +</script> |
| 84 | +</body> |
| 85 | +</html> |
0 commit comments