Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search when page is anything other page 1 doesn't display correctly. #1384

Open
DCMarine opened this issue Sep 26, 2023 · 4 comments
Open

Search when page is anything other page 1 doesn't display correctly. #1384

DCMarine opened this issue Sep 26, 2023 · 4 comments
Labels
wontfix This will not be worked on

Comments

@DCMarine
Copy link

DCMarine commented Sep 26, 2023

Describe the bug
When you are on a page other than page 1 and try to search for item and doesn't return results, then when you clear the search, the grid says its on page one, but data is page two.

To Reproduce
Steps to reproduce the behavior:

  1. On grid with multiple pages advance page past page 1
  2. Search for Item that is in the grid (something from prior page example) - 1st bug.
  3. Now clear the search, select page 1, but is on page 2 data.

Expected behavior
1st - would expect that from the search it would filter from all items not matter what page your on.
2nd - would assume reseting the search would just filter and put select the orignal page you were on, are default back to page 1 with data.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Chrome
  • Version: 116.0.5845.187

Screenshot 2023-09-26 at 2 13 47 PMpage 1 grid no filter
Screenshot 2023-09-26 at 2 13 53 PMresults of running search on page 1
Screenshot 2023-09-26 at 2 14 03 PMresults of same search on page 2
Screenshot 2023-09-26 at 2 17 36 PMresults of removing search on page 2

@DCMarine DCMarine changed the title Search when page is anything other page 1 doesn't work. Search when page is anything other page 1 doesn't display correctly. Sep 26, 2023
@grakenmol
Copy link

Add this code to the pages where you're using the grid and search feature.
It's not perfect, and it skips the first key press, but at the moment, it's good enough.

$(document).ready(function () {
	var gridjs_search_max_try_count = 3;
	var gridjs_search_try_count = 0;

	function addGridjsSearchHook() {
		var grid_count = $('.gridjs')?.length ?? 00;
		if (grid_count == 0) {
			setTimeout(function () {
				addGridjsSearchHook();
			}, 500);
		}
		else {
			if (gridjs_search_try_count <= gridjs_search_max_try_count) {
				gridjs_search_try_count++;
				var search = $('.gridjs input[type="search"]');
				if (search && search.length > 0) {
					$('input[type="search"]').off('keypress');
					// Add the paging reset hook on keydown
					$('input[type="search"]').on('keypress', function (event) {
						event.stopImmediatePropagation();
						var btn = $('.gridjs-pages').children()[1];
						$(btn).trigger('click');
					});
					gridjs_search_try_count = 3;
				}
				else {
					setTimeout(function () {
						addGridjsSearchHook();
					}, 300);
				}
			}
		}
	}
	setTimeout(function () {
		addGridjsSearchHook();
	},1000);
});

@DCMarine
Copy link
Author

DCMarine commented Oct 9, 2023

will this fix make into the primary code line?

@dlavor
Copy link

dlavor commented Oct 20, 2023

will this fix make into the primary code line?

the code above is overkill so definitely not. but it should be fixed somehow for sure

Copy link

stale bot commented Mar 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants