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

Allow to froze multiselect and actions columns if jqgrid sortable property is specified #52

Closed
kobruleht opened this issue Apr 23, 2015 · 22 comments

Comments

@kobruleht
Copy link

Answer in
http://stackoverflow.com/questions/29820226/freeze-rownum-column-in-jqgrid contains code which froozes actions and multiselect column.
This code works only if jqgrid sortable property is not specified.

It should work also if column reordering by using drag and drop is enabled.

actions column reordering can disabled like multiselect checkbox column if this helps to implement this.
It was discussed also in http://www.trirand.com/blog/?page_id=393/bugs/frozen-column-impressions

If in jquery.jqgrid.src.js setFrozenColumns method line 8195

if (p.subGrid === true || p.treeGrid === true || p.cellEdit === true || p.sortable || p.scroll) {

p.sortable || is removed it works but jqgrid header is a bit corrupted. So it looks there are small changes only required for this

@OlegKi
Copy link
Member

OlegKi commented Apr 23, 2015

I have found my own answer which provides the implementation idea. I made the corresponding changes in the code of free jqGrid and now it's supported.

See the demo

To be exactly one can use sortable: true, but it allows to changes the order only non-frozen columns.

@kobruleht
Copy link
Author

I tried .js and css files from git master it with bigger buttons in single toolbar using testcase from question in http://stackoverflow.com/questions/29734580/remove-dancing-effect-in-chrome-from-free-jqgrid-toolbar-buttons-in-font-awesome
Frozen rows are not aligned and Actions column header is duplicated.

Out of sync occurs if browser zoom level is changed. Removing $grid.jqGrid("setFrozenColumns") does not fix this. New code corrupts existing grid layouts.

@OlegKi
Copy link
Member

OlegKi commented Apr 24, 2015

You don't posted the code which you use, so I have to guess. I suppose that you could call setFrozenColumns before you created the navigator bar or you had modified it by call of inlineNav, filterToolbar or by manual moving some elements.

It's clear that there are some situations which can change the height or position of grid. You can inform free jqGrid about the requirement to recalculate the position of the frozen div and the height of its elements. You can trigger jqGridResetFrozenHeights event in the cases

$grid.trigger("jqGridResetFrozenHeights");

You can include the call inside of $(window).resize event handler or to trigger jqGridResetFrozenHeights after making manual changing of any elements of the grid (setting column headers, setting grid header and so on).

@OlegKi
Copy link
Member

OlegKi commented Apr 24, 2015

Try the demo

@kobruleht
Copy link
Author

setFrozenColumns is called after toolbar is created. $grid.trigger("jqGridResetFrozenHeights") is added to window resize event but problem persists.

Make browser window width smaller by resizing or use big zoom level so that toolbar wraps to multiple rows. At some height actions button captions appers 3 times and rows are out of sync.

@OlegKi
Copy link
Member

OlegKi commented Apr 24, 2015

I've found two important problems in your code:

  1. You calls setFrozenColumns twice with one grid $("#grid"): once in the line 944 of your code (inside of GridCommon method) and the second time in the line 1274. setFrozenColumns don't test the wrong usage and just creates an additional frozen columns. So you have full buggy grid at the end
  2. You should remove almost all lines of code of GridCommon function. It should contains only $grid.jqGrid('setFrozenColumns');

@kobruleht
Copy link
Author

I fixed those issues in testcase but problem persists in a bit different flawor. To reproduce, scroll customers list in testcase down and decrease browser window width.
Rows are out of sunc. Tested in Chrome and in IE. If customers list is not scrolled down, problem does not occur.
window.resize calls jqGridResetFrozenHeights :

       $(window).resize(function () { resizeGrid() });


        function resizeGrid() {

            setTimeout( function() {
                var extraToolbarHeight = $('#t_' + $.jgrid.jqID($grid[0].id)).outerHeight(true),
                   toppager_height=$("#grid_toppager").outerHeight(true),
                   messageDivHeight = $('#_messageDiv').is(':visible') ? $('#_messageDiv').outerHeight(true) : 0,
                   header_height=$("div#gview_"+$grid[0].id+" > div.ui-jqgrid-hdiv").outerHeight(true);
                $grid.jqGrid('setGridHeight', $(window).height()
                  -messageDivHeight
                  -$('#contentCaptionDiv').outerHeight(true)
                  -extraToolbarHeight
                  -toppager_height
                  -header_height
                  -1
                  -$("#inputform").outerHeight(true)
                  // -44
                 );



                $("table.ui-jqgrid-btable").each(function () {
                    $(this).trigger("jqGridResetFrozenHeights");
                });

            }, 100 );
            $grid.jqGrid('setGridWidth', $('#grid1container').width(), false);
        }

@OlegKi
Copy link
Member

OlegKi commented Apr 24, 2015

I can't reproduce the problem in my demos and I can't make any modifications of jqGrid code in your demo. I still suppose that the reason is scrollTop position of bDiv and fdDiv (frozen bDiv) will be out of sync. I added one line in the code of myResize used in setFrozenColumns (see here). Please retry with the modified code. I hope that the problem will be solved now.

@kobruleht
Copy link
Author

I updated testcase with changed code but problem persists.
After those operations starting inline edit and up or realoading grid data draws thow black frozen vertical lines in place of actions column and unfrozes actions column content.
Headers are still frozen but actions column contents are no more frozen.

json methods called in testcase allow cross domain calls. So it is possible to save code to local hard drive or to fiddle and run from there. Also I can change testcase so that it includes jqgrid from github or from other place.

@OlegKi
Copy link
Member

OlegKi commented Apr 25, 2015

I made some changes in the code of working with frozen columns in free jqGrid. I hope that the problem is fixed now.

@kobruleht
Copy link
Author

Those changes cause javascript exception if customers table page is opened

Uncaught TypeError: Cannot read property 'top' of undefined Line 8372 Column 39TypeError: Cannot read property 'top' of undefined at fixDiv (http://localhost:52216/admin/Scripts/jqgrid-4.8.0/js/jquery.jqgrid.src.js:8372:39) at HTMLTableElement. (http://localhost:52216/admin/Scripts/jqgrid-4.8.0/js/jquery.jqgrid.src.js:8418:7) at HTMLTableElement.jQuery.event.dispatch (http://localhost:52216/admin/Scripts/jquery-1.11.2.js:4665:9) at HTMLTableElement.elemData.handle (http://localhost:52216/admin/Scripts/jquery-1.11.2.js:4333:46) at Object.jQuery.event.trigger (http://localhost:52216/admin/Scripts/jquery-1.11.2.js:4574:12) at jQuery.fn.extend.triggerHandler (http://localhost:52216/admin/Scripts/jquery-1.11.2.js:5290:24) at HTMLTableElement.updatepager (http://localhost:52216/admin/Scripts/jqgrid-4.8.0/js/jquery.jqgrid.src.js:3241:12) at HTMLTableElement.addJSONData (http://localhost:52216/admin/Scripts/jqgrid-4.8.0/js/jquery.jqgrid.src.js:2907:24) at Object.$.ajax.$.extend.success (http://localhost:52216/admin/Scripts/jqgrid-4.8.0/js/jquery.jqgrid.src.js:3373:23) at fire (http://localhost:52216/admin/Scripts/jquery-1.11.2.js:3143:30)

@OlegKi
Copy link
Member

OlegKi commented Apr 25, 2015

Try once more.

@kobruleht
Copy link
Author

Thank you. Now, if inline editing is started, frozen and unfrozen columns are horizontally at different positions by few pixels.

@kobruleht
Copy link
Author

Colums are at same position only if last row is inline edited. For all other rows, there is difference by few pixels as shown in picture

@OlegKi
Copy link
Member

OlegKi commented Apr 25, 2015

I'm not sure what you mean. If you made the picture under large zoom then it could be less as one pixel. I use in jqGrid internally the tolerance in 1px currently.

You can open developer tools and increase the top property of frozen bDiv in +1px. You will see the results.

The problem that old web browsers and old jQuery versions can't change height or top to less then 1px. I can try to include the pixelTolerance as new jqGrid option and one can try to use 0.1px or less. The most problem would be to make tests in different old web browsers and with different old jQuery version.

@kobruleht
Copy link
Author

Tested in latest Chrome and with jquery 1.11.2

It occurs only at 100% zoom level and only for some tables. If zoom level is increased or decreased during inline edit and then changed back to 100% , this difference disappears. Also if zoom level is 90% or 110% and inline edit is started, it does not occur. It does not occur if there is no horizontal scrollbar in table (all columns fit to screen). It occurs for some tables which have horizontal scollbar.
Since it occurs at 100% zoom level, it is visible to users immediately. If it happened only in other zoom levels, it would not be so important.

@OlegKi
Copy link
Member

OlegKi commented Apr 25, 2015

Sorry, but you don't answered on my question. Do you tried to increase top of frozen-bdiv ui-jqgrid-bdiv to 1px or 2px? You will see the differences. How large is the difference in px which you have?

About your last problrm. I opened http://erp.eetasoft.ee/erp/Grid/Index/Klient in Chrome under 100% zoom and I see absolutely no problem. If you want that I solve the problem you should describe exact test case.

Finally I want to remark, that I get jqGrid sources and make modifications of existing code. So it's important whether there are improvements or there are some new problems which was not exist in jqGrid 4.7.

@kobruleht
Copy link
Author

Chrome show that top is 171px. I changed it to 172px and then difference is bigger (see picture). If I change it to 169px there is no difference.
Have you started inline editing ? It occurs only if inline editing is started in other than last row. I tested with 1024x768 and 1920x1080 resolutions in Chrome and problem appears. Application does not work with jqGrid 4.7 so I cannot test it in 4.7

@OlegKi
Copy link
Member

OlegKi commented Apr 25, 2015

It's difficult for me to read your code, but it's not my goal to debug your code.

Nevertheless I find some very suspected places. In the line 790 of site.css you have the following

.ui-jqgrid tr.jqgrow td {
  height: 2.8em !important;
}

Additionally you set height: 130% for all selects in the grid (!!!???). So the selects have the heigth 50px (48px + 1px border top + 1px border bottom), and the cell have 40px height only (because of height: 2.8em !important;). The option height:100% seems more logical for me

In any way you change somewhere in your code the height of the editing elements. You can find the place and include $grid.trigger("jqGridResetFrozenHeights"); after the changes. Alternatively you can just trugger jqGridResetFrozenHeights with some timeout after starting editing, like

$grid.bind("jqGridInlineEditRow", function () {
    setTimeout(function () {
        $grid.trigger("jqGridResetFrozenHeights");
    }, 100); // or 50 or 300 ???
});

It should solve your problem if I correctly understand its origin.

@kobruleht
Copy link
Author

Line 790 is required to set row height greater according to second and third answer in
http://stackoverflow.com/questions/3203402/jqgrid-set-row-height
otherwize it is very difficult to use jqgrid with tablet computers.

Height 130% also used to make select element to cover whole row height to make it accessible from tablet:

height130

Since there are margins or padding, height 100% does not make select element height to full row height but only partial height as in textboxes in picture. I havent found a way to make textbox height also 100% and increase their fonts. Same style is used also in form editing and correcting them for inline editing makes form editing edit form unreadable. There should be way to increase textbox font size and set its height 100% row height without corrupting edit form. Picture shows that select and cell have same height if height:130% is used for select element.

There is issue about tablet usability in #25 and those remarks belong actually to this issue.

setTimeout in autocomplete is used according to your answer in

http://stackoverflow.com/questions/6847351/how-to-increase-autocomplete-combo-text-element-width-in-form-in-jqgrid

I posed comment there with question is it stil required.

Adding $grid.trigger("jqGridResetFrozenHeights"); fixes the issue thank you.
If setTimeout() is still required this line should added into code sample in this answer also.

@OlegKi
Copy link
Member

OlegKi commented Apr 25, 2015

I think that is you would use box-sizing: border-box; for input and select elements of inline editing then you can do use height: 100% and width: 100%. If you would use Bootstrap than it do the same.

I use the setting box-sizing: border-box; in the filter toolbar and I think to do the setting for cell editing and inline editing too.

@kobruleht
Copy link
Author

I tried this but like I wrote this causes edit form corruption since jqgrid applies this style to edit form elemens also. I posted this in http://stackoverflow.com/questions/29874598/how-to-make-element-sizes-to-fill-cell-sizes-and-increase-font-in-free-jqgrid-in

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

No branches or pull requests

2 participants