-
Notifications
You must be signed in to change notification settings - Fork 195
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
Grid autoresize not working as expecting when autoresizeOnLoad is true #289
Comments
If I correctly understand your problem then you should remove the option |
One more small advices:
As the result you will get shorter code which do the same: http://jsfiddle.net/OlegKi/ejpn9/132/ |
@OlegKi thanks for all the advices. I took this example from one jsfiddle and fork it just to show you what is bothering me. Anyway about hidden columns and how to avoid additional is an excellent advice. In my real case I need 100% width because I have 57(!) columns (don't ask me why) and the left menu which could be hidden. I'm using also autoResize that the columns width are optimised. When the user hide the menu, then the available space for the table extends. But when we refresh the table, the width is back to the initial width, the same when the left menu is visible. You can check this behaviour in my example if you resize the table (drag the middle vertical page bar to the left or to the right ) and click on the "refresh" button. The table will shrink or extend outside the borders. I found out that the I hope I was clear enough what I think it is not expected behaviour of the grid. |
I hope, that I understand correctly your problem now. The demo http://jsfiddle.net/OlegKi/ejpn9/134/ shows how one can fix the problem. It's important to understand that jqGrid holds The code, which I used in the demo http://jsfiddle.net/OlegKi/ejpn9/134/ is the following var applicationGrid = $("#application-list"),
myData = [...];
$(window).on("resize", function() {
var newWidth = applicationGrid.closest(".ui-jqgrid").parent().width();
applicationGrid.jqGrid("setGridWidth", newWidth, true);
});
applicationGrid.on("jqGridAfterLoadComplete", function () {
var colModel = $(this).jqGrid("getGridParam", "colModel"), i, cm;
// reset widthOrg to the new values after autoResizeAllColumns
for (i = 0; i < colModel.length; i++) {
cm = colModel[i];
cm.widthOrg = cm.width;
}
$(window).triggerHandler("resize");
}).jqGrid({
...
}); By the way, it's better to register first the even handler |
The option can improve the behavior of resizing the grid. See the issue #289 for more details.
I posted today some new features in the code of free jqGrid. You can use now practically your original code. You need just to add new autoResizing: {
compact: true,
resetWidthOrg: true
} It will reset the |
This works: http://jsfiddle.net/OlegKi/ejpn9/134/ I guess you have changed the paramter I have one question. Is there any list of what kind of properties are available for options or we must search through the source code. |
Could you describe more exact, which is not working in https://jsfiddle.net/OlegKi/ejpn9/136/? Which web browser you use in the tests? In my tests both https://jsfiddle.net/OlegKi/ejpn9/136/ and http://jsfiddle.net/OlegKi/ejpn9/134/ displays absolutely the same results. I described explicitly in my last comment, that the code from the demo http://jsfiddle.net/OlegKi/ejpn9/134/ works on jqGrid 4.13.6, but https://jsfiddle.net/OlegKi/ejpn9/136/ with more short code (with the option The documentation of full functionality of free jqGrid is complex and there are no full documentation currently. If you know at least the syntax of TypeScript, then free-jqgrid.d.ts could gives you many helpful information. There are exist text editors (like Visual Studio Code), which parse the reference like |
I'm using Google Chrome 56.0.2924.87 (64-bit) on Ubuntu 16.04. I cleared the file cache and the example Thanks about the info about the documentation. It will help me a lot. |
Could you open the file https://rawgit.com/free-jqgrid/jqGrid/master/js/jquery.jqgrid.src.js in your web browser and verify that you can see "2017-02-07" (or higher date) in the comment at the beginning of the file. The picture, which you posted just shows that The demo https://jsfiddle.net/OlegKi/ejpn9/139/, is the combination of http://jsfiddle.net/OlegKi/ejpn9/134/ and https://jsfiddle.net/OlegKi/ejpn9/136/ . It registers |
I can see "2017-02-07" in the file https://rawgit.com/free-jqgrid/jqGrid/master/js/jquery.jqgrid.src.js. When I open https://jsfiddle.net/OlegKi/ejpn9/136/, the table has 100% width. When the window is resized, the width is still 100%. But when I click on "Refresh" button it resized back to It works fine https://jsfiddle.net/OlegKi/ejpn9/139/. |
If you want that the grid be resized after every load and reload then you should call var applicationGrid = $("#application-list"),
myData = [...],
maximizeGrid = function() {
var newWidth = applicationGrid.closest(".ui-jqgrid").parent().width();
applicationGrid.jqGrid("setGridWidth", newWidth, true);
};
$(window).on("resize", maximizeGrid);
applicationGrid.on("jqGridAfterLoadComplete", function () {
maximizeGrid();
}).jqGrid({
data: myData,
...
}).jqGrid('navGrid'); I hope, that everything is clear now. Please close the issue if the problem, which you reported, is solved now. |
Thank you for everything. It works as expected. |
I don't know if this is a bug or a feature. I have prepared the demo: http://jsfiddle.net/ejpn9/128/
The issue is when you resize the table by changing the screen width and then click on
refresh
button or invoketrigger("reloadGrid")
on the grid, the grid is resized to initial width. If you disableautoresizeOnLoad: true,
it works as expected.The workaround is to disable
autoresizeOnLoad: true,
and put intogridComplete
the codeautoResizeAllColumns()
.Can you check and fix (if it is possible)?
The text was updated successfully, but these errors were encountered: