0

ag-grid sorting is not working with another third party plugin. Stimulsoft report.js for reporting tool.

please find plunkr link for the same.

<html>
<head>
      <script src="https://unpkg.com/ag-grid@13.3.1/dist/ag-grid.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/stimulsoft-reports-js@2018.2.3/stimulsoft.reports.js"></script>

 </head>
 <body>

<div id="myGrid" style="height: 100%;" class="ag-fresh"></div>
<script src="main.js"></script>

</body>
</html>    
  • I have no idea what your actual question is. The demo doesn't help. Try to explain what problem you're having. Are you getting an error? – thirtydot Jul 30 '18 at 22:22
  • in plunk sorting on ag-grid doesn't works. due to due to adding stimulsoft report.js. if you remove or comment this line then it works – Shashank Patil Aug 01 '18 at 08:29
  • I see what you're saying. The sorting does *sometimes* work though, you really have to have click around a lot and you can find instances where it doesn't work. For example, the "Age" column always works for me. You have to be specific, "ag-grid sorting is not working" is too vague. Include exact steps. – thirtydot Aug 01 '18 at 12:38

2 Answers2

1

Your problem is likely due to the fact that "Stimulsoft Reports.JS" heavily modifies the native prototypes (String/ Array/Object, at least) in JavaScript, which is almost always a terrible idea.

Their code is bad, in other words.

Here are some supporting links:

As for how to fix it, no idea. It's a long investigation to figure that out.

Try putting the Stimulshaft stuff in a iframe so it can be nice and happy alone to pollute itself.

I'm not even certain that this is the cause, but it probably is. It might be that there's something ag-grid can do to fix it on their end, but it's not their problem. Whatever is happening, it's Stimulshaft's fault.

thirtydot
  • 224,678
  • 48
  • 389
  • 349
  • can we get exact issue then we can convey them (stimulsoft). because i had already issue with base64 class and now they solved from their end. – Shashank Patil Aug 01 '18 at 14:15
  • If you send them a link to this Stack Overflow question (with some additional explanation), they should be able to figure it out. That is, if you're a paying customer and they're willing to put in the time. It's all the `Array.prototype.add=function`/`Object.prototype.toNumber=function` stuff in their code. – thirtydot Aug 01 '18 at 15:40
1

in ag-grid

      ComponentUtil.toNumber = function(value) {
            if (typeof value === 'number') {
                return value;
            } else if (typeof value === 'string') {
                return Number(value);
            } else {
                return undefined;
            }
        }

and in stimulsoft

Object.prototype.toNumber = function() {
   if (this.sti_is(String) && this.indexOf(",") >= 0)
      return Number(this.replaceAll(",", "."));
   return Number(this)
}

so due to this conflict sorting is not able to do.

then i added below lines then solved my issue.

<script>
     Object.prototype.toNumber = undefined;
</script>