Hi I'm using dx data grid in voyager laravel however When I'm inserting a user its id is auto incremented and userid will fetch from db but I don't know how to fetch userid from db.
$("#gridContainer").dxDataGrid({ dataSource: attendances, showBorders: true, hoverStateEnabled: true, showRowLines:true, rowAlternationEnabled:true, selection: { mode: "multiple" }, "export": { enabled: true, fileName: "Employees", allowExportSelectedData: true }, groupPanel: { visible: false }, paging: { pageSize: 10, enabled: true, }, filterRow: { visible: true },
grouping: {
contextMenuEnabled: true,
expandMode: "rowClick"
},
editing: {
mode: "popup",
allowAdding: is_editable,
allowDeleting: is_editable,
allowUpdating: is_editable,
popup: {
title: "Employee Attendance Information",
showTitle: true,
id: "employees->id",
position: "{ my: 'center",
showCloseButton: true
}
},
columns: [{
dataField: 'id',
allowEditing: false,
caption: "id",
width:90,
id: "attendances->id",
},{
dataField: 'user_id',
allowEditing: false,
caption: "User_id",
width:90,
},
{
dataField: "name",
caption: "Name",
allowediting: false,
validationRules: [{ type: "required" },
{
type: "pattern",
pattern: /^[^0-9]+$/,
message: "Do not use digits in the Name."
}]
// lookup: {
// dataSource: name
// }
},
{
dataField: 'attendance_month',
caption: "Attendance Date",
dataType: 'date',
format: " yyyy-MM-dd, EEEE",
allowediting: true,
validationRules: [{ type: "required" }]
},
{
dataField: "attendance_type",
caption: "Attendance Type",
allowediting:true,
validationRules: [{ type: "required" }],
lookup: {
dataSource: [
"present",
"absent",
"onleave"
],
}
}
],
onRowRemoving: function(item) {
$.ajax({
type: 'POST',
dataType: 'json',
url: "",
data: {
'id': item.data.id,
'_method': 'delete'
},
success: function(data) {}
});
},
onRowUpdating: function(item) {
url = "";
$.ajax({
type: 'post',
dataType: 'json',
url: url,
data: {
'id': item.key.id,
'item': item.newData
},
success: function(data) {}
});
},
onRowInserting: function(item) {
$.ajax({
type: 'post',
dataType: 'json',
url: "",
data: {
'item': item.data
},
success: function(data) {
window.location.reload();
}
});
},
onSelectionChanged: function(selectedItems) {
var url = "";
var data = selectedItems.selectedRowsData;
if (data.length > 0) {
selectedArr = $.map(data, function(value) {
return value.id;
});
} else {
$('#createButton').attr("target", "_blank");
$('#createButton').attr("href", "");
}
},
onSelectionChanged: function(selectedItems) {
var url = "";
var data = selectedItems.selectedRowsData;
if (data.length > 0) {
selectedArr = $.map(data, function(value) {
return value.id;
});
} else {
$('#createButton').attr("target", "_blank");
$('#createButton').attr("href", "");
}
},
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire