Pls have a look at http://jsfiddle.net/chugh97/YWVA8/56/ I have frozen the Inv No column. What I want to achieve is freeze the checkbox column only so when some one scrolls the checkbox column is not hidden from user's view.
1 Answers
Recently I answered here on the same question. Nevertheless I find the question very good and I think that the sharing of the solution could be interesting for many users of jqGrid. So I repeat the answer here shortly.
The demo which I created based on the demo from the answer allows not only make the column with the checkboxes be frozen, but additionally allows to implement inline editing together with the frozen columns:
I hope that Tony make the corresponding changes in the main code of jqGrid and the inline editing will be removed from the list of limitations of frozen columns.
The most important part of the code which do the trick is below
$grid.jqGrid('filterToolbar', {stringResult: true, searchOnEnter: false, defaultSearch: "cn"});
$grid.jqGrid('setColProp', 'cb', {frozen: true});
$grid.jqGrid('setGridParam', {multiselect: false});
$grid.jqGrid('setFrozenColumns');
$grid.jqGrid('setGridParam', {multiselect: true});
if($.isFunction($grid[0].p._complete)) {$grid[0].p._complete.call($grid[0]);}
fixPositionsOfFrozenDivs.call($grid[0]);
The implementation of the function fixPositionsOfFrozenDivs
you can find either in the code of the demo or in the text of already referenced old answer.
-
How can I set the frozen property of the column using C# code. JQGridColumn class has a property called "Fixed". Is this the same property which maps to frozen? – chugh97 Jan 25 '12 at 20:57
-
1@chugh97: Probably your question about some commercial product based on the pure JavaScript jqGrid. I don't use this, so can't answer on your question. On the [jqSuite forum](http://www.trirand.net/forum/) one should answer on the question. – Oleg Jan 25 '12 at 21:44
-
I cant find the fbDiv and fhDiv on my source when I try to follow your code to fix position of frozen divs.What I may be doing wrong? – chugh97 Jan 26 '12 at 12:12
-
@chugh97: What you mean under "I cant find the fbDiv and fhDiv"? Do you can show the problem on my code example? If the problem exists in *your code* only you should first verify that the `setFrozenColumns` are called before and it's *successful*. Typical problem is some from [limitations](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:frozencolumns#limitations). Just set the breakpoint on [the line](https://github.com/tonytomov/jqGrid/blob/v4.3.1/js/grid.custom.js#L626) and verify. – Oleg Jan 26 '12 at 12:48
-
What I meant was when I go and see view source of the page, I cannot find fbDiv and fhDiv. The code you sent me from that link checks the existence of the fbDiv and if found then does stuff. – chugh97 Jan 26 '12 at 15:03
-
@chugh97: If you open the source of the page you see the page at the loading time and don't see any changes of the page after changes in the DOM. The grid will be just an empty `
`. Moreover `fbDiv` and `fhDiv` are properties of some DOM elements so here are not parts of HTML markup. You should use some debugger like Developer Tools of IE or Chrome or Firebug for example to examine the page.
– Oleg Jan 26 '12 at 15:16 -
Thanks for your previous comment. The problem is my grid was sortable so I could move columns around (drag and drop). Now my problem is can I set sortable to false and then as per your code freeze the checkbox column and then make the grid sortable again? Looks like jqGrid doc says this is not supported as sortable is assigned only once and cannot be changed. Any pointers to this problem. – chugh97 Jan 27 '12 at 13:50
-
Also noticed that the grid columns can no longer be sorted by the up-down arrow. In your example the sorting is working fine.Any reason why this may be happening? – chugh97 Jan 27 '12 at 14:42
-
To be able to help you I need take a took on the code or better debug the demo (if you post me URL). – Oleg Jan 27 '12 at 15:12