openFromJson() doesn't return a promise, so how do I know when it is complete?

Which event will fire after calling openFromJson() so that I can continue to manipulate the spreadsheet object.  For example:

ss.openFromJson({file: myData});
ss.hideColumn(2,2,true);   //<-- throws error about unassigned properties  



4 Replies

JS Janakiraman Sakthivel Syncfusion Team March 9, 2022 01:43 PM UTC

Hi John, 
 
We can achieve your requirement by using the setTimeout function as shown below. 
 
[index.ts]:  
loadBtn.element.onclick = (): void => { 
        spreadsheet.openFromJson({ file: response.jsonObject }); 
        setTimeout((): void => { 
          spreadsheet.hideColumn(2,2,true); 
        }, 1000); 
    } 
  
For your convenience, we have modified your sample based on your requirement. Please find the link below. 
 
 
 
Could you please check the above links and get back to us, if you need any further assistance on this. 
 
Regards, 
Janakiraman S. 



JO John March 9, 2022 07:39 PM UTC

That seems like a kludge fix to me.  So basically, I'm just guessing at how long I should wait for the task to be completed?   What if it is very large spreadsheet one time and a small one the next?   Is there no EVENT that let's me know exactly when it is complete?



SP Sangeetha Priya Murugan Syncfusion Team March 10, 2022 12:13 PM UTC

Hi John, 
 
Currently we don’t have any event after openFromJson method completes. However, we will check the feasibility of this requirement and update you the further details on March 14th, 2022. We appreciate your patience until then. 
 
Regards, 
Sangeetha M 



SP Sangeetha Priya Murugan Syncfusion Team March 11, 2022 11:16 AM UTC

 
Hi John, 
 
Currently we don’t have any event after the openFromJson method completes. So, we suggest you to use the setColumn method instead of using hideColumn method. SetColumn method sets the hidden property as true in model level. When we load the Json data using openFromJson method cells are re-rendered again, so only the script error occurs. To avoid this, please use setColumn method as like as below. 
 
 
 
loadBtn.element.onclick = (): void => { 
  spreadsheet.openFromJson({ file: response.jsonObject }); 
  var sheet = spreadsheet.getActiveSheet(); 
  setColumn(sheet, 2, { hidden: true }); // set the hidden property as true for particular column in spreadsheet model 
}; 
 
For your convenience, we have prepared the sample based on our above suggestions. Please find the link below. 
 
 
Could you please check the above details and get back to us, if you need any further assistance on this. 
 
Regards, 
Sangeetha M 


Loader.
Up arrow icon