Skip to content

Commit 2868429

Browse files
committed
update employee pdf export
1 parent ac49eab commit 2868429

File tree

2 files changed

+93
-2
lines changed

2 files changed

+93
-2
lines changed

CheckDrive.Web/CheckDrive.Web/Views/Employees/Index.cshtml

+7-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
</div>
4242
</div>
4343
<div class="d-flex col-md justify-content-end create-btn">
44+
<button class="btn btn-primary" onclick="exportToPdf()">Export to PDF</button>
45+
<button class="btn btn-success" onclick="exportToExcel()">Export to Excel</button>
4446
<button id="openModalButton" class="btn btn-success open-modal" type="button" style="width: 15%">
4547
<i class="fa fa-plus"></i> Yangi
4648
</button>
@@ -55,14 +57,17 @@
5557
gridLines="Both"
5658
allowSorting="true"
5759
allowPaging="true"
58-
allowFiltering="true">
60+
allowFiltering="true"
61+
allowPdfExport="true"
62+
allowExcelExport="true"
63+
toolbarClick="onToolbarClick">
5964
<e-grid-selectionsettings mode="Row" type="Single"></e-grid-selectionsettings>
6065
<e-grid-pagesettings pageSize="10"></e-grid-pagesettings>
6166
<e-grid-columns>
62-
<e-grid-column field="AccountId" headerText="Account ID" textAlign="Center" headerTextAlign="Center"></e-grid-column>
6367
<e-grid-column headerText="Ism" field="FirstName" textAlign="Center" headerTextAlign="Center" typeof="text"></e-grid-column>
6468
<e-grid-column headerText="Familiya" field="LastName" textAlign="Center" headerTextAlign="Center" typeof="text"></e-grid-column>
6569
<e-grid-column headerText="Sharfi" field="Patronymic" textAlign="Center" headerTextAlign="Center" typeof="text"></e-grid-column>
70+
<e-grid-column headerText="Passport" field="Passport" textAlign="Center" headerTextAlign="Center"></e-grid-column>
6671
<e-grid-column headerText="Telefon raqam" field="PhoneNumber" textAlign="Center" headerTextAlign="Center" typeof="text"></e-grid-column>
6772
<e-grid-column headerText="Kasb" field="FormattedPosition" textAlign="Center" headerTextAlign="Center" typeof="text"></e-grid-column>
6873
<e-grid-column width="180" type="text" textAlign="Center" template="#actionTemplate"></e-grid-column>

CheckDrive.Web/CheckDrive.Web/wwwroot/js/employees.js

+86
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ function onDetailsClick(id) {
9292
});
9393
}
9494

95+
function onToolbarClick(args) {
96+
let grid = document.getElementById('employees-list').ej2_instances[0];
97+
if (args.item.id === 'employees-list_pdfexport') {
98+
grid.pdfExport();
99+
} else if (args.item.id === 'employees-list_excelexport') {
100+
grid.excelExport();
101+
}
102+
}
103+
95104
$('#detailsModal').on('hidden.bs.modal', function () {
96105
$(this).find('#detailsContent').empty();
97106
});
@@ -135,3 +144,80 @@ $('#createModal').on('hidden.bs.modal', function () {
135144
$(this).find('#accountModalContent').empty();
136145
$(this).off('hidden.bs.modal');
137146
});
147+
148+
function exportToPdf() {
149+
let grid = document.getElementById('employees-list').ej2_instances[0];
150+
grid.pdfExport({
151+
includeHiddenColumn: true,
152+
fileName: 'xodimlar.pdf',
153+
theme: {
154+
header: {
155+
fontName: 'Arial',
156+
fontSize: 14,
157+
size: 16,
158+
bold: true,
159+
italic: false,
160+
color: '#FFFFFF',
161+
background: '#4CAF50' // Header background color
162+
},
163+
record: {
164+
fontName: 'Arial',
165+
fontSize: 12,
166+
size: 14,
167+
color: '#000000'
168+
},
169+
caption: {
170+
fontName: 'Arial',
171+
fontSize: 12,
172+
size: 14,
173+
bold: true,
174+
color: '#333333',
175+
background: '#f8f8f8'
176+
}
177+
},
178+
header: {
179+
fromTop: 0,
180+
height: 130,
181+
contents: [
182+
{
183+
width: 100,
184+
height: 50,
185+
type: 'Text',
186+
value: 'ATP Garaj xodimlari',
187+
position: { x: 250, y: 50 },
188+
style: { textBrushColor: '#3d3d3d', fontSize: 24, bold: true }
189+
},
190+
{
191+
type: 'Text',
192+
value: new Date().toLocaleDateString(),
193+
position: { x: 600, y: 100 },
194+
style: { textBrushColor: '#1f1f1f', fontSize: 16 }
195+
}
196+
]
197+
},
198+
footer: {
199+
fromBottom: 0,
200+
height: 40,
201+
contents: [
202+
{
203+
type: 'Text',
204+
value: '© 2025 Silk Route Connect',
205+
position: { x: 250, y: 20 },
206+
style: { textBrushColor: '#333333', fontSize: 12 }
207+
}
208+
]
209+
},
210+
columns: grid.getColumns().filter(col => col.field !== null && col.field !== undefined)
211+
});
212+
213+
grid.addEventListener('pdfQueryCellInfo', function (args) {
214+
if (args.cell) {
215+
args.style = {
216+
padding: { top: 5, right: 10, bottom: 5, left: 10 }
217+
};
218+
}
219+
});
220+
}
221+
222+
function exportToExcel() {
223+
}

0 commit comments

Comments
 (0)