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
Sai Ram
NA
237
115.9k
Jquery DataTable ReInitialize Not Working
Nov 16 2019 10:04 PM
Hi,
How to destroy and reinitialize the values for datatable. I am not able to achieve this...
HTML
<select id=
'ddlstatus'
<option value=
'Inserted'
>Inserted</option>
<option value=
'Approved'
>Approved</option>
</select>
<table id=
"example"
>
<thead>
<tr>
<th>OrderId</th>
<th>Order</th>
</tr>
</thead>
</table>
JQuery
var dtexample =
'undefined'
;
$(document).ready(function()
{
$(
"#ddlstatus"
).change(function()
{
loadDT();
event
.preventDefault();
});
loadDT();
});
function loadDT()
{
var status = $("#ddlstatus).val();
if
(dtexample !=
'undefined'
)
{
dtexample.destroy();
}
if
(status ==
"Inserted"
)
$(
"#example"
).append(
"<tbody><tr><td>1</td><td>ABC</td></tr></tbody>"
);
else
$(
"#example"
).append(
"<tbody><tr><td>2</td><td>DEF</td></tr></tbody>"
);
dtexample = $("#example).DataTable();
}
Reply
Answers (
1
)
Long url To Short Url.
Long url To Short Url.