|
<html>
<body>
<h1>TypeScript HTML App</h1>
<div id="Grid"></div>
</body>
</html> |
|
/// <reference path="tsfiles/ej.web.all.d.ts" />
/// <reference path="tsfiles/jquery.d.ts" />
module GridComponent {
$(function () {
var gridInstance = new ej.Grid($("#Grid"), {
dataSource: (<any>window).gridData,
allowGrouping: true,
allowSorting: true,
allowMultiSorting: true,
enableAltRow: true,
allowPaging: true,
allowReordering: true,
allowResizing: true,
allowFiltering: true,
allowScrolling: true,
enableRowHover: true,
selectionType: "multiple",
selectionSettings: { enableToggle: true, selectionMode: ["row", "cell", "column"] },
allowKeyboardNavigation: true,
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, allowEditOnDblClick: true, showDeleteConfirmDialog: true },
toolbarSettings: { showToolbar: true, toolbarItems: ["add", "edit", "delete", "update", "cancel", "search"] },
columns: [
{ field: "OrderID", headerText: "Order ID", isPrimaryKey: true, width: 75, textAlign: ej.TextAlign.Right },
{ field: "CustomerID", headerText: "Customer ID", editType: ej.Grid.EditingType.String, width: 80 },
{ field: "EmployeeID", headerText: "Employee ID", width: 75, editType: ej.Grid.EditingType.Dropdown, textAlign: ej.TextAlign.Right, priority: 4 },
{ field: "Freight", width: 75, format: "{0:C}", editType: ej.Grid.EditingType.Numeric, textAlign: ej.TextAlign.Right, priority: 3 },
{ field: "OrderDate", headerText: "Order Date", width: 80, format: "{0:MM/dd/yyyy}", textAlign: ej.TextAlign.Right, priority: 2 },
{ field: "ShipCity", headerText: "Ship City", editType: ej.Grid.EditingType.Dropdown, width: 110, priority: 2 }
],
isResponsive: true,
minWidth: 700,
showSummary: true,
summaryRows: [{ title: "Sum", summaryColumns: [{ summaryType: ej.Grid.SummaryType.Sum, displayColumn: "Freight", dataMember: "Freight", format: "{0:C2}" }] }]
});
});
} |
|
/// <reference path="tsfiles/ej.web.all.d.ts" />
/// <reference path="tsfiles/jquery.d.ts" />
var GridComponent;
(function (GridComponent) {
$(function () {
var gridInstance = new ej.Grid($("#Grid"), {
dataSource: window.gridData,
allowGrouping: true,
allowSorting: true,
allowMultiSorting: true,
enableAltRow: true,
allowPaging: true,
allowReordering: true,
allowResizing: true,
allowFiltering: true,
allowScrolling: true,
enableRowHover: true,
selectionType: "multiple",
selectionSettings: { enableToggle: true, selectionMode: ["row", "cell", "column"] },
allowKeyboardNavigation: true,
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, allowEditOnDblClick: true, showDeleteConfirmDialog: true },
toolbarSettings: { showToolbar: true, toolbarItems: ["add", "edit", "delete", "update", "cancel", "search"] },
columns: [
{ field: "OrderID", headerText: "Order ID", isPrimaryKey: true, width: 75, textAlign: ej.TextAlign.Right },
{ field: "CustomerID", headerText: "Customer ID", editType: ej.Grid.EditingType.String, width: 80 },
{ field: "EmployeeID", headerText: "Employee ID", width: 75, editType: ej.Grid.EditingType.Dropdown, textAlign: ej.TextAlign.Right, priority: 4 },
{ field: "Freight", width: 75, format: "{0:C}", editType: ej.Grid.EditingType.Numeric, textAlign: ej.TextAlign.Right, priority: 3 },
{ field: "OrderDate", headerText: "Order Date", width: 80, format: "{0:MM/dd/yyyy}", textAlign: ej.TextAlign.Right, priority: 2 },
{ field: "ShipCity", headerText: "Ship City", editType: ej.Grid.EditingType.Dropdown, width: 110, priority: 2 }
],
isResponsive: true,
minWidth: 700,
showSummary: true,
summaryRows: [{ title: "Sum", summaryColumns: [{ summaryType: ej.Grid.SummaryType.Sum, displayColumn: "Freight", dataMember: "Freight", format: "{0:C2}" }] }]
});
});
})(GridComponent || (GridComponent = {}));
//# sourceMappingURL=grid.js.map |
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - WebApplication1</title>
<environment include="Development">
<link rel="stylesheet" rel='nofollow' href="~/lib/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" rel='nofollow' href="~/css/site.css" />
<link rel='nofollow' href="~/lib/syncfusion-javascript/Content/ej/web/default-theme/ej.web.all.min.css" rel="stylesheet" />
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/jsrender/jsrender.js"></script>
<script src="~/lib/syncfusion-javascript/Scripts/ej/web/ej.web.all.min.js"></script>
<script src="~/lib/tsfiles/jsondata.min.js"></script>
<script src="~/lib/grid.js"></script>
</environment>
</head>
<body>
<div class="container body-content">
@RenderBody()
</div>
@RenderSection("Scripts", required: false)
<ej-script-manager></ej-script-manager>
</body>
</html>
|
var grid = $("#Grid").ejGrid("instance"); //mention the ID in # tag.
var ejgridSelecteds = grid.getSelectedRecords();
var item = ejgridSelecteds[0];
console.log(item.Auswahlid);
}
<ej-grid id="Grid" allow-sorting="true" allow-paging="true" toolbar-click="onToolBarClick">
<e-datamanager url="..." update-url="Update" insert-url="Insert" remove-url="Delete" adaptor="WebApiAdaptor">e-datamanager>
<e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true">e-edit-settings>
<e-toolbar-settings show-toolbar="true" toolbar-items='@new List<string>{"add","edit","delete","update","cancel"}'>
<e-custom-toolbar-items>
<e-custom-toolbar-item template-id="#Produkte">e-custom-toolbar-item>
e-custom-toolbar-items>
e-toolbar-settings>
<e-columns>
<e-column field="auswahlid" header-Text="Auswahl Id" width="75" text-align="Right">e-column>
<e-column field="bezeichnung" header-Text="Bezeichnung" width="80" text-align="Right">e-column>
<e-column field="bemerkung" header-Text="Bemerkung" width="75" text-align="Right">e-column>
<e-column field="creationdate" header-Text="Creation date" width="80" edit-type="Datepicker" format="{0:MM/dd/yyyy}" textAlign="right">e-column>
e-columns>
ej-grid>
I don´t want to use javascript but typescript (analog to Angular) if I implement Events. Is that possible and does it supported? Or should I prefer to use Javascript in this case, because Javascript is better documented and there are several examples on your site?
Example: Should I implement this example in Javascript or Typescript? Is there any difference if I use typescript instead of Javascript?
function onToolBarClick(args) {
var grid = $("#Grid").ejGrid("instance");
var ejgridSelecteds = grid.getSelectedRecords();
var item = ejgridSelecteds[0];
console.log(item.auswahlid);
}
Regards
Anis Helaoui
}
id="Grid"></div>
[component.ts]
GridComponent { $(function () { var gridInstance = new ej.Grid($("#Grid"), dataSource: window["gridData"], [ field: "OrderID", isPrimaryKey: true }, field: "ShipCountry" } |