<html>
<head>
<script src="//code.jquery.com/jquery.min.js"></script>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" type="text/css" />
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="//da7xgjtj801h2.cloudfront.net/2014.2.716/js/kendo.all.min.js"></script>
<link href="//da7xgjtj801h2.cloudfront.net/2014.2.716/styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="//da7xgjtj801h2.cloudfront.net/2014.2.716/styles/kendo.rtl.min.css" rel="stylesheet" type="text/css" />
<link href="//da7xgjtj801h2.cloudfront.net/2014.2.716/styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
<script src="https://dl.dropboxusercontent.com/u/3997430/upload/codex/bootstrap-contextmenu.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div id="container" >
<div id="grid"></div>
</div>
<div id="context-menu">
<ul class="dropdown-menu" >
<li>
<i class="icon-trash"></i>
<span> Action 1</span>
</li>
<li>
<i class="icon-list-alt"></i>
<span> Action 2</span>
</li>
<li>
<i class="icon-random" style="margin-right:3px"></i>
<span>Action 3</span>
</li>
</ul>
</div>
</body>
</html>
//button template
var btnMenu = $('<span /><button class="btn btn-mini" data-toggle="context" data-target="#context-menu"> <i class="icon-th"></i> <span class="caret"></span></button>');
//bind left click
btnMenu.click(function (e) {
e.stopPropagation();
//clicked button
var obj = $(this);
//get dataItem
var uid = obj.closest("tr").attr("data-uid");
var dataItem = $("#grid").data("kendoGrid").dataSource.getByUid(uid);
$("#context-menu").find("span:first").text("OrderID: " + dataItem.OrderID);
obj.contextmenu('show', e);
});
//add buttons
function onDatabound(e) {
btnMenu.appendTo('tbody > tr > td:first-child');
}
$("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
},
schema: {
model: {
fields: {
OrderID: { type: "number" },
CustomerID: { type: "string" },
ShippedDate: { type: "date" },
OrderDate: { type: "date" },
RequiredDate: { type: "date" },
ShipName: { type: "string" },
ShipAddress: { type: "string" },
ShipRegion: { type: "string" },
ShipPostalCode: { type: "string" },
ShipCountry: { type: "string" }
}
}
},
pageSize: 10,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
dataBound: onDatabound,
sortable: true,
filterable: true,
resizable:true,
columnMenu: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
columns: [
{
field: "CustomField",
width: 100
}, {
field: "OrderID",
format: "{0}",
title: "Order ID",
width: 100
}, {
field: "CustomerID"
}, {
field: "ShippedDate",
format: "{0:d}",
filterable: true
}, {
field: "OrderDate",
format: "{0:d}",
filterable: true
}, {
field: "RequiredDate",
format: "{0:d}",
filterable: true
}, {
field: "ShipCountry",
title: "Ship Country",
width: 130
}, {
field: "ShipName",
title: "Ship Name",
width: 200
}
]
});
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |