0

I am curious what is p.nv property in jqgrid columns. This is being using inside dragEnd() function in jqgrid.

dragEnd: function() {
this.hDiv.style.cursor = "default";
if(this.resizing) {
 var idx = this.resizing.idx,
 nw = this.headers[idx].newWidth || this.headers[idx].width;
 nw = parseInt(nw,10);
 this.resizing = false;
 $("#rs_m"+$.jgrid.jqID(p.id)).css("display","none");
 p.colModel[idx].width = nw;
 this.headers[idx].width = nw;
 this.headers[idx].el.style.width = nw + "px";
 this.cols[idx].style.width = nw+"px";
  if(this.footers.length>0) {this.footers[idx].style.width = nw+"px";}
   if(p.forceFit===true){
  nw = this.headers[idx+p.nv].newWidth || this.headers[idx+p.nv].width;
  this.headers[idx+p.nv].width = nw;
  this.headers[idx+p.nv].el.style.width = nw + "px";
  this.cols[idx+p.nv].style.width = nw+"px";
  if(this.footers.length>0) {this.footers[idx+p.nv].style.width = nw+"px";}
   p.colModel[idx+p.nv].width = nw;
 } 
I'm Geeker
  • 4,601
  • 5
  • 22
  • 41
Aakash
  • 7
  • 6
  • It's a very strange question. Do you want to understand the code of `dragStart`, `dragMove`, `dragEnd`? **Which version of jqGrid you use?** I can comment the meaning of `nv` if you want. The `nv` will be used **only if `forceFit: true`** is set. `nv` is the index of the next visible column after the column which will be resized. The parameter `nv` will be set inside of `mousedown`. By the way I rewrote the code in free jqGrid (see [here](https://github.com/free-jqgrid/jqGrid/blob/v4.13.3/js/grid.base.js#L2931-L2949)) using additional `resizeColumn` function. – Oleg Jul 14 '16 at 16:35

1 Answers1

0

It seems that you included the first part of the code dragEnd from some old version of jqGrid. At least the code of dragEnd from version 4.7 looks the same.

The parameter nv (p.nv) will be initialized to 0 initially (see here) and it will be used inside of dragMove (see here) and dragEnd (see here) only if the option forceFit: true is set. In the case the option nv will be set to the index in colModel of the next visible column (nv come from the next visible) after the resizing column inside of mousedown event handler (see here) before dragStart be started.

By the way I rewrote the code in free jqGrid to allow to move separater between the columns outer of the grid. It's very helpful during resizing of the last column of the grid.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • yeah its old version i guess. I wanted to know about this because for setting the column width i am using your provided solution http://stackoverflow.com/questions/20012365/how-to-adjust-the-column-width-of-jqgrid-after-the-data-is-loaded. > I am using setColWidth with false since i want to hold the original grid. Issue is when i am dragging a column and while reszing again i am calling the setColWidth with false, since p.nv is changed to some value from 0 ,i am ending up updating width of a column either which is wrong or not present and getting a script error. – Aakash Jul 14 '16 at 17:22
  • @user2009877: `setColWidth` is the part of jqGrid methods in free jqGrid fork, which I develop. Probably you need to reset `nv` to 0 before call of `setColWidth`. – Oleg Jul 14 '16 at 19:46