tonytomov / jqGrid

jQuery grid plugin
www.trirand.com
2.85k stars 1.2k forks source link

`footerData` destroy frozen cols when it's inside `jqGridAfterLoadComplete` event #1071

Open fredsal opened 1 month ago

fredsal commented 1 month ago

This worked in previous versions, it is a breaking change?

v5.8.8 Demo: https://jsfiddle.net/x05efgj6/2/ (try moving horizontal scrollbar, there is no frozen cols, but there is frozen header)

image

// here is the event
$("#jqGrid").on('jqGridAfterLoadComplete',()=>{         
    // here destroys frozen columns
    // I change it dynamically because I put a value that I recalculate in each `jqGridAfterLoadComplete`
   $("#jqGrid").footerData('set',{CategoryName:'MyFooter'})
});

This worked without problems before, am I doing something wrong??


I did found the problem, now there is destroyFrozen arg on footerData method https://github.com/tonytomov/jqGrid/blob/7b23577790f4720c8b8f0e722534b8065f7799c7/js/grid.base.js#L6784 and it is true by default https://github.com/tonytomov/jqGrid/blob/7b23577790f4720c8b8f0e722534b8065f7799c7/js/grid.base.js#L6796

tonytomov commented 2 weeks ago

Glad to hear you have found a solution. Sorry for the late response

angeljqv commented 2 weeks ago

Sorry for the late response

Don't worry, you have a personal life like everyone else.

you have found a solution

I did found the problem, but it seems like a breaking change, this change was quite unexpected

tonytomov commented 2 weeks ago

Actually there is a option userDataOnFooter which actually do the same you do.

If you really need this maybe you will need to call the command within setTimeout.

Regards

angeljqv commented 2 weeks ago

you will need to call the command within setTimeout.

It is to simulate an ajax call, which is the moment where the problem happens, without ajax nothing happens

there is a option userDataOnFooter which actually do the same you do.

In the example, userDataOnFooter is being used, or am I using it wrong? Because I get the footer data from the FRONT

tonytomov commented 2 weeks ago

If you comment the code in jqGridAfterLoadComplete everthing will be ok. In this case you call it two times one after other. Please look this code in the source: https://github.com/tonytomov/jqGrid/blob/master/js/grid.base.js#L3192

The same apply to JSON data.

tonytomov commented 2 weeks ago

Sorry I mean you will need to comment the event and stay only with the lines like this:

$("#jqGrid").jqGrid({
    datatype: "local",
    mtype: "POST",
    colModel: [
      { label: 'Category Name', name: 'CategoryName', width: 75, frozen:true },
            { label: 'Product Name', name: 'ProductName', width: 300 },
            { label: 'Country', name: 'Country', width: 200 },
            { label: 'Price', name: 'Price', width: 80 },
            { label: 'Quantity', name: 'Quantity', width: 80 }                   
        ],      
        width: 450,height: 200, autowidth:false, shrinkToFit:false,
    footerrow:true
  });
  $("#jqGrid").footerData('set',{CategoryName:'MyFooter'})
  $("#jqGrid").jqGrid('setFrozenColumns');

};
angeljqv commented 2 weeks ago

Sorry I mean you will need to comment the event and stay only with the lines like this:

Yes that works, I'll try to explain myself again

// I change it dynamically because I put a value that I recalculate in each jqGridAfterLoadComplete

I reload the ajax grid periodically, I set footerData on every load, I make calculations based on an indicator entered in the FRONT END, so, the footer is not fixed like the example, i set fixed word 'MyFooter' just for show the problem

with frozen columns, footerData on jqGridAfterLoadComplete fails, loadComplete option also fails

This worked correctly in previous versions, look: https://jsfiddle.net/jLycz4kg/ Also, one part is frozen and the other is not, it looks like a bug.

here I used setInterval, so you can see the footer change: https://jsfiddle.net/vj9Lfe56/1/

angeljqv commented 2 weeks ago

using jqGridAfterGridComplete, first ajax load fails, second works look: https://jsfiddle.net/0rh7setf/