Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // cài đặt bảng
- $('#MainTable').DataTable({
- 'paging': true,
- 'lengthChange': true,
- 'searching': true,
- 'ordering': true,
- 'info': true,
- 'autoWidth': true,
- 'aoColumnDefs': [{
- 'bSortable': false,
- 'aTargets': ['nosort']
- }]
- });
- ý nghĩa các thuộc tính
- - paging: phân trang
- - lengthChange: tự thay đổi độ dài của cột
- - searching: có ô search hay không
- - ordering: có auto sort hay không
- - info: cái này không biết
- - autoWidth: tự động chỉnh chiều rộng
- - aoColumnDefs: danh sách các định nghĩa riêng: cái cột có class = nosort => cột này không sort
- // cài đặt bảng
- <table id="MainTable" class="table table-bordered table-hover">
- <thead>
- <tr>
- <th>No.</th>
- <th>@Html.DisplayNameFor(Model => Model.LeaveVMForDisplay.UserName)</th>
- <th>@Html.DisplayNameFor(Model => Model.LeaveVMForDisplay.LeaveType)</th>
- <th>@Html.DisplayNameFor(Model => Model.LeaveVMForDisplay.WorkShift)</th>
- <th>@Html.DisplayNameFor(Model => Model.LeaveVMForDisplay.FromDate)</th>
- <th>@Html.DisplayNameFor(Model => Model.LeaveVMForDisplay.ToDate)</th>
- <th class="table_align_center">@Html.DisplayNameFor(Model => Model.LeaveVMForDisplay.State)</th>
- <th name="LeaveID" hidden>LeaveID</th>
- </tr>
- </thead>
- <tbody>
- @{
- int i = 1;
- foreach (var item in Model.LeaveVM)
- {
- <tr>
- <td>@i.ToString()</td>
- <td>@Html.DisplayFor(m => item.UserName)</td>
- <td>@Html.DisplayFor(m => item.LeaveType)</td>
- <td>@Html.DisplayFor(m => item.WorkShift)</td>
- <td>@Html.DisplayFor(m => item.FromDate)</td>
- <td>@Html.DisplayFor(m => item.ToDate)</td>
- @if (item.State == TSM.Data.Models.Leave.eState.OnQueue)
- {
- <td class="table_align_center"><label class="label label-warning"> Waiting </label></td>
- }
- else
- {
- if (item.State == TSM.Data.Models.Leave.eState.Approved)
- {
- <td class="table_align_center"><label class="label label-success">Approved</label></td>
- }
- else
- {
- <td class="table_align_center"><label class="label label-danger">Rejected</label></td>
- }
- }
- <td hidden>@item.LeaveID</td>
- </tr>
- i++;
- }
- }
- </tbody>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement