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

jqgrid paging breaks when using groupingView due to additional sortByColumns on POST request #108

Closed
webdevilopers opened this issue May 20, 2014 · 4 comments

Comments

@webdevilopers
Copy link
Contributor

I added groupingView to my jqgrid layout in order to add summary on my footerrow:

var grid_<?php echo $this->gridId; ?> = $('#<?php echo $this->gridId; ?>').jqGrid({
    // ...
    grouping: true,
    groupingView : {
        groupField : ['contract_id'],
        groupSummary : [true],
        groupColumnShow : [false],
        groupText : [' '],
        groupCollapse : false,
        groupDataSorted : false,
        groupSorted: false,
        //groupOrder: ['asc']
        //groupOrder: [false]
    groupOrder: []
    },    
    // ...    

The pagination will fail with a 500 Internal Server Error and the following message from ZfcDatagrid on the POST request:
Count missmatch order columns/direction

The regular POST params without groupingView will result in:

columnsGroupBy    
columnsHidden    id,contract_id
currentPage    2
isSearch    false
itemsPerPage    5
nd    1400510371968
sortByColumns    
sortDirections   

Using groupView it will add the sortByColumns:

columnsGroupBy    
columnsHidden    id,contract_id
currentPage    2
isSearch    false
itemsPerPage    5
nd    1400510295168
sortByColumns    contract_id asc,
sortDirections 

I have tried several jqgrid groupingView setups but could not override the sortByColumns.

This issue may be related to other issues and improvements:

@webdevilopers
Copy link
Contributor Author

So far I can tell that we will have to check the renderer class for the sortConditions method @ThaDafinser :
https://github.com/ThaDafinser/ZfcDatagrid/blob/master/src/ZfcDatagrid/Renderer/JqGrid/Renderer.php#L47

I switched the Person Bootstrap example to jQuery and took a look at the default config:

    sortname: 'displayName,givenName',
    sortorder: 'ASC,DESC',

    prmNames : {
        page: 'currentPage',
        rows: 'itemsPerPage',
        sort: 'sortByColumns',
        order: 'sortDirections',
        search: 'isSearch',
    },

The major problem is that - when using groupingView - the sortDirections are being passed inside the sortByColumns instead of separating them.

We will have to check if this is a general jqGrid behaviour or the default separation is created by this module.

Looking at the jqGrid example I think you can set a default sort and order that will not be changed and every sort and order inside the groupingView will be added separately including the order. The sortDirection will be left out.

This will look like this:
Image of jqGrid Wiki
Full example: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:grouping

Maybe we should "simply" check if the order asc or desc is included and then no longer look for the matching POST value inside sortDirections.
If there was a feature for ZfcDatagrid to set groupingView we could even make the mentioned validation depend on that setting. But we should start with a quick solution first.

webdevilopers added a commit to webdevilopers/ZfcDatagrid that referenced this issue Jun 17, 2014
@webdevilopers
Copy link
Contributor Author

Here is the solution for regular and groupingView sorting @ThaDafinser :
https://github.com/webdevilopers/ZfcDatagrid/blob/master/src/ZfcDatagrid/Renderer/JqGrid/Renderer.php#L47-102

I havn't made it a PR yet since there still are some old issues to be (or not to be) merged.

I will try to add an example based based on the jqGrid demo 38:

This will take some time! Until then other people can use an individual layout, create the groupingView and check the sorting.

There are some tricky things to consider when using sorting on groupingView e.g. it makes no sense to group on a column invdate but still allow the user to sort on it manually since jqGrid will simply overwrite it. But thes are jqGrid "issues" and we should at least mention them in the docs.

If groupingView becomes a feature and will be generated by the Renderer we could possibly disable user sorting on Columns used for grouping. But that's all still up in the air.

@webdevilopers
Copy link
Contributor Author

I created a PR in a separated branch @ThaDafinser . Could you please test the functionality with the new example?

There are some differences in the behaviour of the ZfcDatagrid example and the JqGrid example when you use sorting Inv No or Date. But we could check this later since it is no "bug".

@ThaDafinser
Copy link
Owner

This issue was moved to zfc-datagrid/zfc-datagrid#12

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

No branches or pull requests

2 participants