[ Mini Kiebo ]
Server: Windows NT AKFAR_SERVER 10.0 build 26200 (Windows 10) AMD64
Path:
D:
/
xampp
/
htdocs
/
simaku-aset
/
application
/
views
/
admin
/
master
/
[
Home
]
File: gedung_js.php
<script type="text/javascript"> $(document).ready(function() { $("#search").keyup(function() { var searchValue = $('#search').val(); $("#grid").data("kendoGrid").dataSource.filter({ field: "building_name", operator: "Contains", value: searchValue }); }); deleteDialogTemplateitem = kendo.template($("#deleteDialogTemplateitem").html()); $('#grid').kendoGrid({ dataSource: { transport: { read: function(options) { $.ajax({ dataType: 'json', url: '<?= base_url("master/building/show") ?>', type: 'get', data: options.data, success: function(res) { options.success(res); }, error: function(xhr, ajaxOptions, thrownError) { console.log(ajaxOptions); } }) }, create: function(options) { $.ajax({ headers: { "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content") }, url: '<?= base_url("master/building/store") ?>', type: "post", data: options.data, dataType: "json", complete: function(e) { $('#grid').data("kendoGrid").dataSource.read(); swal('Berhasil', 'Anda berhasil menambah data', "success"); }, error: function(xhr, ajaxOptions, thrownError) { swal({ title: thrownError, text: 'Error!! ' + xhr.status, type: "error", confirmButtonColor: "#02991a", confirmButtonText: "Refresh Serkarang", cancelButtonText: "Tidak, Batalkan!", closeOnConfirm: false, }, function(isConfirm) { if (isConfirm) { window.location.reload( true ) // submitting the form when user press yes } }); } }); }, update: function(options) { $.ajax({ headers: { "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content") }, url: '<?= base_url("master/building/update") ?>', type: "post", data: options.data, dataType: "json", complete: function(e) { $('#grid').data("kendoGrid").dataSource.read(); swal('Berhasil', 'Anda berhasil mengubah data', "success"); }, error: function(xhr, ajaxOptions, thrownError) { swal({ title: thrownError, text: 'Error!! ' + xhr.status, type: "error", confirmButtonColor: "#02991a", confirmButtonText: "Refresh Serkarang", cancelButtonText: "Tidak, Batalkan!", closeOnConfirm: false, }, function(isConfirm) { if (isConfirm) { window.location.reload( true ) // submitting the form when user press yes } }); } }); }, }, schema: { data: 'data', total: 'total', model: { id: "id", } }, pageSize: 20 }, editable: 'popup', toolbar: [{ name: 'create', text: 'Tambah Data' }], edit: function(e) { e.container.parent().find('.k-window-title').text(e.model.isNew() ? "Tambah Data" : "Ubah Data"); }, sortable: true, pageable: { refresh: true, pageSizes: true, buttonCount: 5 }, columns: [{ field: "building_name", title: "Nama Gedung", width: 100 }, { field: "building_code", title: "Kode", width: 100 }, { field: "notes", title: "keterangan", width: 100 }, { headerTemplate: "<span class='k-icon k-i-gear'></span>", headerAttributes: { class: "table-header-cell", style: "text-align: center" }, attributes: { class: "table-cell", style: "text-align: center" }, command: ['edit', { name: "tampil", iconClass: "k-icon k-i-close", text: "Hapus", click: deleteData }, ], width: "150px" }] }); function deleteData(e) { //start delete item var detailRow = e.detailRow; e.preventDefault(); var tr = $(e.target).closest("tr"), data = this.dataItem(tr); var deleteDialog = $("#ItemDelete").kendoDialog({ width: "350px", title: "Hapus Data", visible: false, buttonLayout: "stretched", actions: [{ text: "Hapus", primary: true, action: function(e) { $.ajax({ headers: { "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr( "content") }, url: '<?= base_url("master/building/destroy") ?>', type: "post", data: { id: data.id }, dataType: "json", beforeSend: function() { // setting a timeout console.log(this.data); }, success: function(e) { if (e['deleted'] == 3) { swal('Berbahaya', 'Data ini MASIH terhubung dengan data lainya, akan berbahaya jika di hapus', "warning"); } else { $('#grid').data("kendoGrid").dataSource .read(); swal('Berhasil', 'Anda berhasil menghapus data', "success"); } }, error: function(xhr, ajaxOptions, thrownError) { swal({ title: thrownError, text: 'Error!! ' + xhr.status, type: "error", confirmButtonColor: "#02991a", confirmButtonText: "Refresh Serkarang", cancelButtonText: "Tidak, Batalkan!", closeOnConfirm: false, }, function(isConfirm) { if (isConfirm) { window.location.reload( true ) // submitting the form when user press yes } }); } }); } }, { text: "Batal" } ] }).data("kendoDialog"); deleteDialog.content(deleteDialogTemplateitem(data)); deleteDialog.open(); } //end delete funtion }) </script>