@page
@model Its.Pages.Voyages.indexModel
@{
ViewData["Title"] = "index";
var ddlShips = new Syncfusion.EJ2.DropDowns.DropDownList()
{
DataSource = Model.ShipsDataSource,
Query = "new ej.data.Query()",
Fields = new Syncfusion.EJ2.DropDowns.DropDownListFieldSettings() { Value = "ShipName", Text = "ShipName" }
};
List<object> ContextMenuitems = new List<object>();
ContextMenuitems.Add(new { text = "Create Invoice", target = ".e-content", id = "createinvoice" });
}
@Html.AntiForgeryToken()
<div class="col-lg-12 control-section">
<ejs-grid id="Grid" locale="nl" actionBegin="actionBegin" rowSelected="rowSelected" allowFiltering="true" allowSorting="true" allowPaging="true" load="onLoad"
toolbar="@( new List<object>() {"Add","Edit","Delete","Update","Cancel"})"
contextMenuItems="ContextMenuitems" contextMenuClick="contextMenuClick">
<e-grid-editsettings allowAdding="true" allowDeleting="true" allowEditing="true" showDeleteConfirmDialog="true"></e-grid-editsettings>
<e-data-manager url="/Voyages/Index?handler=DataSource" insertUrl="/Voyages/Index?handler=Insert" updateUrl="/Voyages/Index?handler=Update" removeUrl="/Voyages/Index?handler=Delete" adaptor="UrlAdaptor"></e-data-manager>
<e-grid-filterSettings type="CheckBox"></e-grid-filterSettings>
<e-grid-pageSettings pageSize="15"></e-grid-pageSettings>
<e-grid-columns>
<e-grid-column field="VoyageId" headerText="Id" isPrimaryKey="true" validationRules="@(new { required = true, number = true })" visible="false"></e-grid-column>
<e-grid-column field="ShipName" headerText="Schip" editType="dropdownedit" edit="new {@params = ddlShips }" width="120px"></e-grid-column>
<e-grid-column field="Reference" headerText="Ref" validationRules="@(new { required = true })" width="90px"></e-grid-column>
<e-grid-column field="TravelFrom" headerText="Van" validationRules="@(new { required = true })" width="120px"></e-grid-column>
<e-grid-column field="TravelTo" headerText="Naar" validationRules="@(new { required = true })" width="120px"></e-grid-column>
<e-grid-column field="Tonnage" headerText="Tonnage" validationRules="@(new { required = true })" editType="numericedit" format="N3" edit="@(new {@params = new { format = "N3" }})" textAlign="Right" width="120px"></e-grid-column>
<e-grid-column field="Product" headerText="Product" validationRules="@(new { required=true})" width="100px"></e-grid-column>
<e-grid-column field="StartDate" headerText="Start" editType="datetimepickeredit" textAlign="Right" width="120px"></e-grid-column>
<e-grid-column field="DepartDate" headerText="Vertrek" editType="datetimepickeredit" textAlign="Right" width="120px"></e-grid-column>
<e-grid-column field="ArrivalDate" headerText="Aankomst" editType="datetimepickeredit" textAlign="Right" width="120px"></e-grid-column>
<e-grid-column field="EndDate" headerText="Eind" editType="datetimepickeredit" textAlign="Right" width="120px"></e-grid-column>
<e-grid-column field="Freetime" headerText="Freetime" editType="numericedit" validationRules="@(new { required=true})" format="N0" textAlign="Right" width="100px"></e-grid-column>
<e-grid-column field="Rate" headerText="Rate" format="C2" textAlign="Right" validationRules="@(new { required=true})" width="100px"></e-grid-column>
<e-grid-column field="RatePerHour" headerText="Uurtarief" format="C2" validationRules="@(new { required=true})" textAlign="Right" width="100px"></e-grid-column>
<e-grid-column field="Overtime" headerText="Overtime" format="C2" validationRules="@(new { required=true})" textAlign="Right" width="100px"></e-grid-column>
<e-grid-column field="Lumpsum" headerText="Lumpsum" format="C2" validationRules="@(new { required=true})" textAlign="Right" width="120px"></e-grid-column>
<e-grid-column field="ProvisionPercentage" headerText="%" editType="numericedit" validationRules="@(new { required=true})" format="P2" textAlign="Right" width="100px"></e-grid-column>
<e-grid-column field="Freight" headerText="Vracht" allowEditing="false" format="C2" textAlign="Right" width="140px"></e-grid-column>
<e-grid-column field="Provision" headerText="Provisie" allowEditing="false" format="C2" textAlign="Right" width="120px"></e-grid-column>
<e-grid-column field="Demurrage" headerText="Demurrage" allowEditing="false" format="C2" textAlign="Right" width="120px"></e-grid-column>
<e-grid-column field="DemurrageProvision" headerText="Provisie" allowEditing="false" format="C2" textAlign="Right" width="120px"></e-grid-column>
<e-grid-column field="Total" headerText="Totaal" allowEditing="false" format="C2" textAlign="Right" width="120px"></e-grid-column>
</e-grid-columns>
</ejs-grid>
</div>
<script>
function onLoad() {
this.dataSource.dataSource.headers = [{ 'XSRF-TOKEN': $("input:hidden[name='__RequestVerificationToken']").val() }];
this.columns[7].format = { type: 'date', format: 'dd/MM/yyyy' };
this.columns[8].format = { type: 'date', format: 'dd/MM/yyyy' };
this.columns[9].format = { type: 'date', format: 'dd/MM/yyyy' };
this.columns[10].format = { type: 'date', format: 'dd/MM/yyyy' };
}
function actionComplete() {
return false;
}
var ddlShips = @Json.Serialize(Model.ShipsDataSource);
function actionBegin(args)
{
if (args.requestType === "save") {
args.data['ShipId'] = ddlShips.filter(function (d) { return d.ShipName === args.data['ShipName'] })[0].ShipId;
}
}
var VoyageId;
function rowSelected(args){
console.log(args.data.VoyageId);
VoyageId = args.data.VoyageId
}
function contextMenuClick(args) {
if (args.item.id === 'createinvoice') {
console.log(VoyageId);
//document.location = '/Voyages?handler=CreateInvoice';
}
}
document.addEventListener('DOMContentLoaded', function () {
loadCultureFiles('nl');
});
</script>