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

Issues with w2grid autoLoad #2073

Open
gitgitwhat opened this issue Jul 18, 2021 · 0 comments
Open

Issues with w2grid autoLoad #2073

gitgitwhat opened this issue Jul 18, 2021 · 0 comments

Comments

@gitgitwhat
Copy link

Short description
There are a few issues with w2grid and loading from remote sources. First, I can't seem to get 'Load More' more to show. I've studied this example (http://w2ui.com/web/demos/#/combo/9) but there doesn't seem to be anything different than what I'm doing so not sure how to make the 'Load More' show. Second, multiple requests are made initially when the page loads. Third, I have to use preventDefault() in onLoad so that I can process the returned data or else the grid gets cleared. I don't know if the two later issues are intended behaviors but it seems off.

Here are the console.trace() during page load for the onRequest method. I don't understand why it is being triggered so many times.

main.js:2547 console.trace
onRequest @ main.js:2547
trigger @ w2ui-1.5.min.js:2
request @ w2ui-1.5.min.js:2
load @ w2ui-1.5.min.js:2
reload @ w2ui-1.5.min.js:2
skip @ w2ui-1.5.min.js:2
DoCreateGrid @ main.js:2583
onClick @ main.js:251
trigger @ w2ui-1.5.min.js:2
(anonymous) @ w2ui-1.5.min.js:2
setTimeout (async)
click @ w2ui-1.5.min.js:2
onclick @ (index):1

main.js:2547 console.trace
onRequest @ main.js:2547
trigger @ w2ui-1.5.min.js:2
request @ w2ui-1.5.min.js:2
load @ w2ui-1.5.min.js:2
reload @ w2ui-1.5.min.js:2
render @ w2ui-1.5.min.js:2
(anonymous) @ w2ui-1.5.min.js:2
setTimeout (async)
refresh @ w2ui-1.5.min.js:2
html @ w2ui-1.5.min.js:2
DoCreateGrid @ main.js:2581
onClick @ main.js:251
trigger @ w2ui-1.5.min.js:2
(anonymous) @ w2ui-1.5.min.js:2
setTimeout (async)
click @ w2ui-1.5.min.js:2
onclick @ (index):1

main.js:2547 console.trace
onRequest @ main.js:2547
trigger @ w2ui-1.5.min.js:2
request @ w2ui-1.5.min.js:2
load @ w2ui-1.5.min.js:2
reload @ w2ui-1.5.min.js:2
render @ w2ui-1.5.min.js:2
(anonymous) @ w2ui-1.5.min.js:2
setTimeout (async)
refresh @ w2ui-1.5.min.js:2
refresh @ w2ui-1.5.min.js:2
render @ w2ui-1.5.min.js:2
(anonymous) @ w2ui-1.5.min.js:2
setTimeout (async)
refresh @ w2ui-1.5.min.js:2
html @ w2ui-1.5.min.js:2
DoCreateGrid @ main.js:2578
onClick @ main.js:251
trigger @ w2ui-1.5.min.js:2
(anonymous) @ w2ui-1.5.min.js:2
setTimeout (async)
click @ w2ui-1.5.min.js:2
onclick @ (index):1

main.js:2547 console.trace
onRequest @ main.js:2547
trigger @ w2ui-1.5.min.js:2
request @ w2ui-1.5.min.js:2
load @ w2ui-1.5.min.js:2
reload @ w2ui-1.5.min.js:2
render @ w2ui-1.5.min.js:2
(anonymous) @ w2ui-1.5.min.js:2
setTimeout (async)
refresh @ w2ui-1.5.min.js:2
refresh @ w2ui-1.5.min.js:2
render @ w2ui-1.5.min.js:2
(anonymous) @ w2ui-1.5.min.js:2
setTimeout (async)
refresh @ w2ui-1.5.min.js:2
refresh @ w2ui-1.5.min.js:2
render @ w2ui-1.5.min.js:2
(anonymous) @ w2ui-1.5.min.js:2
setTimeout (async)
refresh @ w2ui-1.5.min.js:2
html @ w2ui-1.5.min.js:2
DoCreateGrid @ main.js:2575
onClick @ main.js:251
trigger @ w2ui-1.5.min.js:2
(anonymous) @ w2ui-1.5.min.js:2
setTimeout (async)
click @ w2ui-1.5.min.js:2
onclick @ (index):1

Here is a reduced example based on the example cited above. I've purposely limited the number of rows just to try to get the 'Load More' link to show but it never does.

Steps to reproduce or sample

function AddRows(json) {
   //...
   //parse and push records
   //...
   w2ui['grid'].refresh();
}

		let config = {
			layout: {
				name: 'layout',
				panels: [
					{ type: 'main', style: gStyle, content: 'main'}
			        ]
			},
			grid: {
				name: 'grid',
				url: cmd,
				autoLoad: false,
				limit: 3,
				columns: [
					{ field: 'id', text: 'id', hidden:true },
					{ field: 'title', text: 'Title', size: '100%' },
				],
				onRequest: function(event) {
                                        //Modify the url by adding some custom parameters
					event.url += mod_request;
				}, 
				onLoad: function(event) {
                                        //Without this, the grid won't show any records.
					event.preventDefault();
					AddRows(event.xhr.responseText);
				}
			}
		}

		$().w2layout(config.layout);
		w2ui.layout.html('main', w2ui['layout']);

		$().w2grid(config.grid);
		w2ui.layout.html('main', w2ui['grid']);
		w2ui.grid.autoLoad = false;
		w2ui.grid.skip(0);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant