Skip to content

Commit

Permalink
Tipo calling set group header
Browse files Browse the repository at this point in the history
  • Loading branch information
tonytomov committed Oct 9, 2011
1 parent e96a017 commit ade9106
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion js/grid.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2918,7 +2918,7 @@ $.jgrid.extend({
}
if($t.p.groupHeader && (typeof $t.p.groupHeader === 'object' || $.isFunction($t.p.groupHeader) ) ) {
$($t).jqGrid('destroyGroupHeader');
$($t).jqGrid('setGroupHeader',$t.p.groupHeader);
$($t).jqGrid('setGroupHeaders',$t.p.groupHeader);
}
});
},
Expand Down

11 comments on commit ade9106

@OlegKi
Copy link
Contributor

@OlegKi OlegKi commented on ade9106 Oct 9, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Tony!

I see that you works on the setGroupHeaders implementation. I worked yesterday also on the problem. So I decide, that it can be helpful if you see in which direction I worked. You can see here the current state. The most problems are solve. One have to make changes in the remapColumns mostly. The modified version of jqGrid modules are grid.base.js and grid.custom.js. I fixed small problem with resizable: false columns. I save the original value of the width parameter in widthOrg to hold the grid without horizontal scrolling after the column re-sizing if the grid was created without any fixed width value. Moreover I hope that I changed the problem with shrinkToFit: true correctly. The setting forceFit:true should also work now. By the way my changes are implied also for the standard grids (without multiline headers). I had to add one more parameter in setGridWidth to make shrinkToFit work correct in case of column resizing. The standard setting which I used to use is shrinkToFit: false, so please verify whether I did the changes like as should be.

Moreover I extended $("#list")[0].grid object with additional information. Additionally I extended colModel with groupHeader. Look additionally in the grid.colIndexByName map. I think it could be helpful in many places in the jqGrid.

I stop working on jqGrid for some hours to allow you to examine my changes and to decide what which way to choose.

Please look additionally the part where I increase the size of "span.ui-jqgrid-resize" and adjust position of "div.ui-jqgrid-sortable" inside of the column headers. I think one could find the better way to have full height of the "span.ui-jqgrid-resize". My current implementation work, but I don't like it really. What I additionally not like is the constants like "padding-top": "2px", height: "19px" in the code. Probably one can more use CSS classes, but the usage of "!important" attribute for resizing in the current jqGrid implementation of jqGrid (I mean your existing code) makes difficult to change the height of the span.

Best regards
Oleg

@tonytomov
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Oleg,
Thanks I will look right now in the changes.
The VERY IMPORTANT problem for me is how to restore the original header when useColSpanStyle is set to true using the destroyGridHeader method.
The is the most important for me. All other problems are at second place.

Regards
Tony

@tonytomov
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oleg,
When we have a correct working destroyGroupHEader (in booth cases) then all other thing like show/hide cols, soratble columns and etc will work, since we will destroy the header before these actions and apply it after them

Regards
Tony

@OlegKi
Copy link
Contributor

@OlegKi OlegKi commented on ade9106 Oct 9, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK Tony, I am back at home now and will look your version of the code. I will look and try to modify destroyGridHeader method. In general I looked on the setGroupHeaders method mostly as on the method which will be called internally during jqGrid initialization. One can make it public, but to permit to call it once. I thought that one don't need to create or destroy the grouping header dynamically. The parameters of setGroupHeaders method could be parameters of jqGrid in the final implementation. In the most cases either one needs multiline headers in the grid at the beginning or one don't not need multiline headers at all. It's exactly like one currently can't insert/delete new column in the grid dynamically. In the same way one could be not able to manipulate by columns headers.

Nevertheless I will read your version of the destroyGridHeader and will try to fix the problem which probably exist in the current implementation. I will let you known after I progress in the subject.

Regards
Oleg

@OlegKi
Copy link
Contributor

@OlegKi OlegKi commented on ade9106 Oct 9, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Tony,

I modified the code of destroyGroupHeader method in the version which I posted you before. The same code with minimal modifications will work in your version too. In the file you can find my current implementation of the destroyGroupHeader method. You can use the demo to test it. I included in the code of setGroupHeaders additionally simple test whether the method will be called not the first time. In the case will be done nothing.

I will examine your version of the code and will fix the code of remapColumns.

Regards
Oleg

@OlegKi
Copy link
Contributor

@OlegKi OlegKi commented on ade9106 Oct 9, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way you can use the demo to test what work and what still not work in the current code.

Regards
Oleg

@OlegKi
Copy link
Contributor

@OlegKi OlegKi commented on ade9106 Oct 10, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Tony,

in the next version of the demo the most important problems in the remapColumns are solved now. There are still some small problems (see comment with TODO which I not yet done), but because tomorrow I will have to work on other things I decide post the current state.

Best regards
Oleg

@tonytomov
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Oleg,
I do not think that currently sortable columns should be compatible with group header - too complicated and too much code.
My goal is to make this simple as possible and do not put a ton of other grid options and colmodel additions.
For now I plan to stay on this variant making just some fixes.
I have tested with show/hide column and it work ok. Rtl is working ok too.
Will make other tests tomorrow
What do you think about this?

Tony

@OlegKi
Copy link
Contributor

@OlegKi OlegKi commented on ade9106 Oct 11, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Tony,

I like also short and good readable code, but first of all one should make the code work correctly and then simplify/improve it. At the beginning I didn't want to implement column resorting at all, but then I found one problem. The only official supported column hider/shower dialog is columnChooser and it has one important problem. If some hidden column exist (like Tax or Id columns in the demo) and one want just to show the hidden columns the columnChooser adds the columns at the end of the column list and not at the original position. This behavior makes the implementation of remapColumns as required.

By the way. The current implementation has one bug which I didn't yet fixed. To reproduce the bug one should do the following steps in the demo:

  1. create the grid with the standard settings and add column headers using useColSpanStyle:true
  2. using the columnChooser move the "Date" column between "Shipping" and "Notes" and click OK.
  3. using the columnChooser move the "Date" column between "Total" and "Closed" and click OK. If any hidden column exists in the bottom header row (like "Tax"), the header movement work incorrect.

I have to drive to my customer now. If you would have time you can examine the problem. It would be additionally very good if you could change the behavior of the columnChooser so that it places the hidden column at it's original position if the user just click on the "+" on the right of the hidden column.

Best regards
Oleg

@tonytomov
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oleg,
My opinion is - sfter every such action including - show/hide/ remapcolumns/ columnChosser and etc we should apply destroy and rebuild again the group header after this action finished (like I do in showHideColumns)- simple like KISS.

Regards

@OlegKi
Copy link
Contributor

@OlegKi OlegKi commented on ade9106 Oct 11, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tony,

I thought about the way. I agree that it could be pragmatical way for the first step. The disadvantage of the way is in the customization. If one set the column text of some other column property dynamically then all the settings will be discarded. So for the standard grid destroying and rebuilding of the grid headers could be good pragmatical way, but it could have some important disadvantages in more complex scenarios. Inside of destroyGroupHeader I thought about the problem and so tried I move existing <th> elements. So many kind of customization will be hold, but other will be do destroyed.

I agree, that the way eliminate many problems. Probably I though about the possible problems which are not exist too seldom. Introduction an additional event afterDestroyGroupHeader or afterRebuildGroupHeader could solve the rest problems. So the way with destroying and rebuilding of the grid headers would be enough.

Best regards
Oleg
P.S. My congratulation with the release of jqGrid 4.2.0!

Please sign in to comment.