javascript - Paginate the result after search
Get the solution ↓↓↓i need your help please hier. i have a table inside a form, and in that table i load data from database in to it. Everything work how i expected, i have also a small plugins to paginate my table on tbody. i'm trying hier to make a live search, and it's working to but the pagination stay always the same and the Result after Search it's showing in one Page with a lot of data, but i want the Result to be also paginated. i tried this code but it seem strange when i delete the text in '#mysearch' textbox doesn't returned more data and stay fixed on the first search i did. i know there is some plugins like dataTable but that make my whole css work destroyed and i have also in that Table somebutton to do some Action but after dataTable they don't work anymore. that way i want to this without dataTable. PS: i'm hiding first the normal pagination '$('.pagination').hide();' otherwise it will be twice there.
-i'm working with Doctrine and Zend Framework, jquery , bootstrap.
can someone help me please ? or if you have other idea please let me know.
$("#MySearch").keyup ( function () {
var value = $(this).val().toLowerCase();
$.each($('table tbody tr td .searchNumber'), function () {
if ($(this).val().toLowerCase().indexOf(value) == -1) {
$(this).closest("#sbrow").hide();
} else {
$('.pagination').hide();
$(this).closest("#sbrow").show();
}
});
var x = $('table tbody > tr:not([style*="display: none"])').length;
var arr = $('table tbody > tr:not([style*="display: none"])');
$('table tbody').empty().append(arr);
if (x <= 10) {
$('table tbody').paginathing({
perPage: 10,
limitPagination: 1,
insertAfter: '#myForm',
pageNumbers: true
});
} else if (x <= 20) {
$('table tbody').paginathing({
perPage: 10,
limitPagination: 2,
insertAfter: '#myForm',
pageNumbers: true
});
} else if (x <= 30) {
$('table tbody').paginathing({
perPage: 10,
limitPagination: 3,
insertAfter: '#myForm',
pageNumbers: true
});
} else if (x <= 40) {
$('table tbody').paginathing({
perPage: 10,
limitPagination: 4,
insertAfter: '#myForm',
pageNumbers: true
});
} else if (x <= 50) {
$('table tbody').paginathing({
perPage: 10,
limitPagination: 5,
insertAfter: '#myForm',
pageNumbers: true
});
} else {
$('table tbody').paginathing({
perPage: 10,
limitPagination: 6,
insertAfter: '#myForm',
pageNumbers: true
});
}
});
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: malformed utf-8 characters, possibly incorrectly encoded
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.