TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mohsin Arif
307
6k
138.6k
initComplete not working ?
Mar 16 2020 7:31 AM
below is my code i load data from model. in MVC but filter is not showing in data table
<script>
$(document).ready(function () {
var table = $(
'#tableReport'
).DataTable({
initComplete: function () {
this
.api().columns().every(function () {
var column =
this
;
var select = $(
'<select><option value=""></option></select>'
)
.appendTo($(column.footer()).empty())
.on(
'change'
, function () {
var val = $.fn.dataTable.util.escapeRegex(
$(
this
).val()
);
column
.search(val ?
'^'
+ val +
'$'
:
''
,
true
,
false
)
.draw();
});
column.data().unique().sort().each(function (d, j) {
select.append(
'<option value="'
+ d +
'">'
+ d +
'</option>'
)
});
});
},
'columnDefs'
: [
{
'targets'
: 0,
'checkboxes'
: {
'selectRow'
:
true
}
}
],
'select'
: {
'style'
:
'multi'
},
'order'
: [[1,
'asc'
]]
});
// Handle form submission event
$(
'#frm-Report'
).on(
'submit'
, function (e) {
var form =
this
;
var arr =
new
Array();
var ReportID = $(
"#ReportId"
).val();
var DateFrom = $(
'#startDate'
).val();
var DateTo = $(
'#endDate'
).val();
var start =
new
Date(DateFrom);
var end =
new
Date(DateTo);
if
(start <= end) {
var rows_selected = table.column(0).checkboxes.selected();
if
(rows_selected.length == 0) {
SendNotif(
"Ooopss!"
,
"No User is Selected"
,
'error'
);
return
false
;
}
// Iterate over all selected checkboxes
$.each(rows_selected, function (index, rowId) {
// Create a hidden element
arr.push(rowId);
$(form).append(
$(
'<input>'
)
.attr(
'type'
,
'hidden'
)
.attr(
'name'
,
'id[]'
)
.val(rowId)
);
});
$(
".se-pre-con"
).fadeIn(
"slow"
);
if
(document.location.pathname.includes(
"Reports"
)) {
FormSubmitReport(arr, DateFrom, DateTo, ReportID);
}
else
{
FormSubmitGenrate(arr, DateFrom, DateTo);
}
}
else
{
SendNotif(
'Error!'
,
'Invalid Date Range'
,
'error'
);
}
// Prevent actual form submission
e.preventDefault();
});
function FormSubmitReport(arr, DateFrom, DateTo, ReportID) {
window.location =
'/Report/Generate?data='
+ arr +
'?'
+ DateFrom +
'?'
+ DateTo +
'?'
+ ReportID;
}
function FormSubmitGenrate(arr, DateFrom, DateTo) {
window.location =
'/Adjustment/Generate?data='
+ arr +
'?'
+ DateFrom +
'?'
+ DateTo;
}
});
</script>
Reply
Answers (
1
)
How to implement DDD architecture with onion architecture ?
Platform for kiosk software