iT邦幫忙

0

datatable功能權限相關問題

我想請問datatable顯示的這個錯誤是顯示在「刪」的部分有錯誤,請問應該怎麼修改呢?
登入管理員的帳號密碼是正常的沒有錯誤,但登入其他的帳號密碼卻顯示此錯誤。
https://ithelp.ithome.com.tw/upload/images/20210104/20132806VC0cUac7RQ.png

以下是程式碼的部分,謝謝!

$(document).ready(function() {});
				$.ajax({
					url: "cust_search.php",
					type: "POST",
					cache: false,
					success: function(data) {
						const parseData = JSON.parse(data);
						$('#empTable').DataTable({
							autoWidth: false,
							language: {
								"processing": "處理中...",
								"loadingRecords": "載入中...",
								"lengthMenu": "顯示 _MENU_ 項結果",
								"zeroRecords": "沒有符合的結果",
								"info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
								"infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
								"infoFiltered": "(從 _MAX_ 項結果中過濾)",
								"search": "輸入公司名稱關鍵字:",
								"paginate": {
									"first": "第一頁",
									"previous": "上一頁",
									"next": "下一頁",
									"last": "最末頁"
								},
								"aria": {
									"sortAscending": ": 升冪排列",
									"sortDescending": ": 降冪排列"
								},
								"select": {
									"1": "%d 列已選擇",
									"2": "%d 列已選擇",
									"_": "%d 列已選擇"
								}
							},
							"columnDefs": [{
								//設置第二列、第四列不參與搜索
								"targets": [1, 3],
								"searchable": false
							}],
							"lengthMenu": [20],
							"pagingType": "full_numbers",
							"bLengthChange": false, //關閉每頁顯示多少條數據
							"processing": true,
							"ServerSide": true, //伺服器端處理(物理分頁)
							"aoColumns": [{
									"width": "5%",
									"sTitle": "功能",
									"mRender": function(data, type, row, meta) {
										<?php
										if ($guserrole != "業務") {
										?>
											return '<a href="cust_update.php?id=' + row.idad_customer + '" class="edit">' + '</a>';
										<?php } ?>
									},
									"bSortable": false

								},
								{
									"width": "10%",
									"mData": "type"
								},
								{
									"width": "20%",
									"sTitle": "委刊公司",
									"mData": "name"
								},
								{
									"width": "10%",
									"sTitle": "聯絡人",
									"mData": "contact",
								},
								{
									"width": "5%",
									"sTitle": "刪",
									"mRender": function(data, type, row, meta) {
										<?php
										if ($guserrole == "管理員") {
										?>
											return '<a href="javascript:void(0);" onClick="del(' + row.idad_customer + ')"class="del">' + '</a>';
										<?php } ?>
									},
									"bSortable": false
								},
							],
							"aaData": parseData,
						});
					}
				});
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
海綿寶寶
iT邦大神 1 級 ‧ 2021-01-05 09:29:53

最底下那段

"mRender": function(data, type, row, meta) {
    <?php
    if ($guserrole == "管理員") {
    ?>
    return '<a href="javascript:void(0);" onClick="del(' + row.idad_customer + ')"class="del">' + '</a>';
    <?php } ?>
},

改成

"mRender": function(data, type, row, meta) {
    return '<a href="javascript:void(0);" onClick="del(' + row.idad_customer + ')"class="del">' + '</a>';
},

試試看

我要發表回答

立即登入回答