Rendering problem with .setSourceDataAtCell()

Tags: #<Tag:0x00007efc62540b90> #<Tag:0x00007efc62540a50>

Hi,

I’m having problems with .setSourceDataAtCell() in this function:

$.ajax({
                url: '/main/calculations/get-mode-level-octaves',
                method: 'GET',
                data: {
                    'mode_id': mode_id
                },
                success: function(data){                
                    changes.push([row, 8, data.noiseLevel]);                    
                    changes.push([row, 9, data.f63]);
                    changes.push([row, 10, data.f125]);
                    changes.push([row, 11, data.f250]);
                    changes.push([row, 12, data.f500]);
                    changes.push([row, 13, data.f1000]);
                    changes.push([row, 14, data.f2000]);
                    changes.push([row, 15, data.f4000]);
                    changes.push([row, 16, data.f8000]);                        
                    hot.setSourceDataAtCell(changes);                                                                                
                    resolve();                            
                }                
            });

in some more or less specific cases, the changes will not appear visible in the table. The changes variable looks exactly as I would expect it to, but no values will appear in the table. In the same cases it will always work if I use .setDataAtCell() instead. changes is exactly the same in both cases. I’d prefer to not use .setDataAtCell() here because it triggers the afterChange hook and i dont want to trigger that here.

I realize that this is a very broad question and it probably depends on the rest of my code but are there any obvious reasons I could look into to explain and fix this behaviour?

Thanks!

Hi @notaflyin

In this case it would be best you could prepare a code demo in which we can observe the error and reproduce the issue. Then we can try to find a source of the problem.

Hi Adrian,

i tried reproducing the error with a simple demo in a jsFiddle and there it just worked. I then threw my entire code into this fiddle (https://jsfiddle.net/wubbe/b6hkp9ur/18/), just modifying the afterChange so that when something is selected in Column “Mode”, it just writes a 10 in column 10 instead of the function in my original post. that also worked fine. the same code, including the modification does not work in my own webpage. the 10 does not get displayed.

However, if instead of changes.push([row, 10, 10]); I use changes.push([row, 10, ‘=ROUND(10, 1)’]); (using Hyperformula) it gets displayed correctly.
Also, the Hyperformulas in the last 3 columns, that depend on the numbers put in by the function in my original Post, always displayed the correct result. even though there were no numbers visible in the cells they are referencing.

Modifying my original function to this made it work in the edge cases where it didnt before:

$.ajax({
            url: '/main/calculations/get-mode-level-octaves',
            method: 'GET',
            data: {
                'mode_id': mode_id
            },
            success: function(data){                
                changes.push([row, 8, '=ROUND('+data.noiseLevel+',1)']);                    
                changes.push([row, 9, '=ROUND('+data.f63+',1)']);
                changes.push([row, 10, '=ROUND('+data.f125+',1)']);
                changes.push([row, 11, '=ROUND('+data.f250+',1)']);
                changes.push([row, 12, '=ROUND('+data.f500+',1)']);
                changes.push([row, 13, '=ROUND('+data.f1000+',1)']);
                changes.push([row, 14, '=ROUND('+data.f2000+',1)']);
                changes.push([row, 15, '=ROUND('+data.f4000+',1)']);
                changes.push([row, 16, '=ROUND('+data.f8000+',1)']);                    
                hot.setSourceDataAtCell(changes);                                                                                
                resolve();                            
            }                
        });

That’s a workaround but it bugs me…

Hi @notaflyin

Just to clarify things, the current solution you implemented works as expected both in the example you sent, and your local project, right? I don’t see anything worrying in the code snippet you shared, so if that works I would go with this solution.

yeah, it works in both applications. If there’s other obvious error that would explain my Problem i will Just leaves it like that for now. thank you.

@notaflyin

Thank you for the update. I will close this topic in that case.