Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- var vehicleCreateDialog, vehicleEditDialog;
- $(function () {
- $('#vehicleTable').DataTable({
- processing: true,
- serverSide: true,
- ajax: {
- "url": "@(Url.Action("GetAllForDataTable", "Vehicles"))",
- "type": "POST",
- "datatype": "json",
- "data": function (data) {
- data.MinYearOfProduction = document.getElementById("vehicleFilters_MinYearOfProduction").value;
- data.MaxYearOfProduction = document.getElementById("vehicleFilters_MaxYearOfProduction").value;
- data.ChassisNumber = document.getElementById("vehicleFilters_ChassisNumber").value;
- data.TypeOfDrive = document.getElementById("vehicleFilters_TypeOfDrive").value;
- data.MinAllowedPackage = document.getElementById("vehicleFilters_MinAllowedPackage").value;
- data.MaxAllowedPackage = document.getElementById("vehicleFilters_MaxAllowedPackage").value;
- data.VehicleMarkingType = document.getElementById("vehicleFilters_VehicleMarkingType").value;
- data.MinNumberOfSeats = document.getElementById("vehicleFilters_MinNumberOfSeats").value;
- data.MaxNumberOfSeats = document.getElementById("vehicleFilters_MaxNumberOfSeats").value;
- data.TypeOfPurchase = document.getElementById("vehicleFilters_TypeOfPurchase").value;
- data.Description = document.getElementById("vehicleFilters_Description").value;
- }
- },
- columnDefs: [
- { "targets": [0], "visible": false, "searchable": false },
- { "targets": [1], "visible": true, "searchable": true },
- { "targets": [2], "visible": true, "searchable": true },
- { "targets": [3], "visible": true, "searchable": true },
- { "targets": [4], "visible": true, "searchable": true },
- { "targets": [5], "visible": true, "searchable": true },
- { "targets": [6], "visible": true, "searchable": true },
- { "targets": [7], "visible": true, "searchable": true },
- { "targets": [8], "visible": true, "searchable": true },
- { "targets": [9], "visible": true, "searchable": false, "orderable": false },
- ],
- columns: [
- { "data": "id", "name": "Id", "autoWidth": true },
- { "data": "institutionName", "name": "Lokalizacja", "autoWidth": true },
- { "data": "group", "name": "Grupa", "autoWidth": true },
- { "data": "producer", "name": "Marka", "autoWidth": true },
- { "data": "model", "name": "Model", "autoWidth": true },
- { "data": "registrationNumber", "name": "Numer rej.", "autoWidth": true },
- { "data": "lastOdometerValue", "name": "Przebieg", "autoWidth": true },
- { "data": "status", "name": "Status", "autoWidth": true },
- { "data": "isAvailable", "name": "Czy dostępny", "autoWidth": true },
- {
- data: "id", name: "Actions", autoWidth: true,
- render: function (data, row) {
- var mainDiv = $("<div>", {
- class: "dropdown"
- })
- $("<button>", {
- class: "btn btn-primary dropdown-toggle",
- attr: {
- type: "button",
- "data-toggle": "dropdown",
- }
- }).text("Akcje").appendTo(mainDiv);
- var mainUl = $("<ul>", {
- class: "dropdown-menu"
- });
- if ("@((
- User.IsInRole(Roles.Admin) ||
- User.IsInRole(Roles.Tab_MobileResources_EditBasicData) ||
- User.IsInRole(Roles.Tab_MobileResources_ChangeInstitution) ||
- User.IsInRole(Roles.Tab_MobileResources_ChangeOdometerValue) ||
- User.IsInRole(Roles.Tab_MobileResources_ChangeTechnicalInspectionExpiration)
- ) ? "1" : "0")" === "1") {
- var menuSep = $("<div>", {
- class: "dropdown-header",
- css: {
- color: "green"
- }
- }).text("Podstawowe")
- mainUl.append(menuSep);
- if ("@((User.IsInRole(Roles.Tab_MobileResources_EditBasicData) || User.IsInRole(Roles.Admin)) ? "1" : "0")" === "1"){
- menuSep.append(
- $("<button>", {
- class: "dropdown-item btn btn-outline",
- type: "button",
- })
- .text("Edytuj pojazd")
- .on('click', function (e) {
- console.log("test");
- })
- );
- }
- if ("@((User.IsInRole(Roles.Tab_MobileResources_ChangeInstitution) || User.IsInRole(Roles.Admin)) ? "1" : "0")" === "1") {
- menuSep.append(
- $("<li>").html(
- $("<button>", {
- class: "dropdown-item btn btn-outline",
- type: "button"
- }).text("Zmień lokalizację")
- ));
- }
- if ("@((User.IsInRole(Roles.Tab_MobileResources_ChangeOdometerValue) || User.IsInRole(Roles.Admin)) ? "1" : "0")" === "1") {
- menuSep.append(
- $("<li>").html(
- $("<button>", {
- class: "dropdown-item btn btn-outline",
- type: "button"
- }).text("Zmień wartość licznika")
- ));
- }
- if ("@((User.IsInRole(Roles.Tab_MobileResources_ChangeTechnicalInspectionExpiration) || User.IsInRole(Roles.Admin)) ? "1" : "0")" === "1") {
- menuSep.append(
- $("<li>").html(
- $("<button>", {
- class: "dropdown-item btn btn-outline",
- type: "button"
- }).text("Zmień termin badań technicznych")
- ));
- }
- }
- mainDiv.append(mainUl);
- return mainDiv.html();
- }
- },
- ],
- initComplete: function () {
- var col_Id = this.api().columns(0);
- var col_institutionName = this.api().columns(1);
- var col_group = this.api().columns(2);
- var col_producer = this.api().columns(3);
- var col_model = this.api().columns(4);
- var col_registrationNumber = this.api().columns(5);
- var col_lastOdometerValue = this.api().columns(6);
- var col_status = this.api().columns(7);
- var col_isAvailable = this.api().columns(8);
- //====================================== 1
- $("<input>", {
- id: "col1_filter",
- class: "column_filter form-control form-control-sm",
- attr: {
- type: "text",
- placeholder: "Wyszukaj"
- }
- })
- .appendTo($(col_institutionName.footer()).empty())
- .on('change', function () {
- col_institutionName.search(
- $('#col1_filter').val()
- ).draw();
- });
- //====================================== 2
- $("<input>", {
- id: "col2_filter",
- class: "column_filter form-control form-control-sm",
- attr: {
- type: "text",
- placeholder: "Wyszukaj"
- }
- })
- .appendTo($(col_institutionName.footer()).empty())
- .on('change', function () {
- col_institutionName.search(
- $('#col2_filter').val()
- ).draw();
- });
- //====================================== 3
- $("<input>", {
- id: "col3_filter",
- class: "column_filter form-control form-control-sm",
- attr: {
- type: "text",
- placeholder: "Wyszukaj"
- }
- })
- .appendTo($(col_group.footer()).empty())
- .on('change', function () {
- col_group.search(
- $('#col3_filter').val()
- ).draw();
- });
- //====================================== 4
- $("<input>", {
- id: "col4_filter",
- class: "column_filter form-control form-control-sm",
- attr: {
- type: "text",
- placeholder: "Wyszukaj"
- }
- })
- .appendTo($(col_producer.footer()).empty())
- .on('change', function () {
- col_producer.search(
- $('#col4_filter').val()
- ).draw();
- });
- //====================================== 5
- $("<input>", {
- id: "col5_filter",
- class: "column_filter form-control form-control-sm",
- attr: {
- type: "text",
- placeholder: "Wyszukaj"
- }
- })
- .appendTo($(col_model.footer()).empty())
- .on('change', function () {
- col_model.search(
- $('#col5_filter').val()
- ).draw();
- });
- //====================================== 6
- $("<input>", {
- id: "col6_filter",
- class: "column_filter form-control form-control-sm",
- attr: {
- type: "text",
- placeholder: "Wyszukaj"
- }
- })
- .appendTo($(col_registrationNumber.footer()).empty())
- .on('change', function () {
- col_registrationNumber.search(
- $('#col6_filter').val()
- ).draw();
- });
- },
- });
Add Comment
Please, Sign In to add comment