Is there a way to reset the dataSource when the popup is closed?

Hello, 

as mentioned in the subject, I would like to know if there is a way to reset, or remove, the dataSource, when the dropdown is closed.

Thanks.


2 Replies

SM Shalini Maragathavel Syncfusion Team August 30, 2021 12:37 PM UTC

Hi Nicola, 

Greetings from Syncfusion support.
 
We checked your query and would like to let you know that currently we do not have direct support to reset the data source when popup is closed in Dropdown Tree component. So, we are validating the reported scenario at our end. We will update further details on September 2nd  2021. Until then, we appreciate your patience. 

Regards,
Shalini M.
 



SM Shalini Maragathavel Syncfusion Team September 1, 2021 12:08 PM UTC

Hi Nicola, 

Thanks for your patience.
 
We have validated your requirement to remove/reset the data source while opening/closing the Dropdown Tree popup. You can achieve this requirement by assigning the data source to the Dropdown in the beforeOpen event and empty it in the close event as demonstrated in the below code snippet. 
export class Default extends SampleBase { 
  constructor() { 
    this.temp = false; 
  } 
  beforeOpen() { 

    if (this.temp == true) { 
      this.fields = { value: 'id', text: 'name', child: 'subChild', dataSource: dataSource.defaultData1}; 
      this.temp = false; 
    } 
    else { 
      this.fields = { value: 'id', text: 'name', child: 'subChild', dataSource: dataSource.defaultData}; 
      this.temp = true; 
    } 
    this.dataBind(); 
  } 
  close() { 
   this.fields = { value: 'id', text: 'name', child: 'subChild', dataSource: []}; 
  } 
  render() { 
    return ( <DropDownTreeComponent 
                fields={this.fields} 
                beforeOpen={this.beforeOpen} 
                close={this.close} 
              />  
    ); 
  } 


Note: While
removing the data source from dropdown tree, selected values will also be removed.

Please find the below sample for your reference
 

Please get back to us if you need further assistance.

Regards,
Shalini M. 


Loader.
Up arrow icon