|
export class Default extends SampleBase {
render() {
// Mapping Tab items Header property
let headertext = [{ text: "Tab1"}, { text: "Tab2"}, { text: "Tab3"}];
// render the other components as the separate functions like below
function contentTemplate1(){
return(<ButtonComponent>Click me</ButtonComponent>);
}
function contentTemplate2(){
return(<DatePickerComponent></DatePickerComponent>);
}
function contentTemplate3() {
return( <CalendarComponent ></CalendarComponent>);
}
return (<div className='control-pane'>
<TabComponent heightAdjustMode='Auto' id='defaultTab'>
<TabItemsDirective>
//refer that functions as content
<TabItemDirective header={headertext[0]} content={contentTemplate1}/>
<TabItemDirective header={headertext[1]} content={contentTemplate2}/>
<TabItemDirective header={headertext[2]} content={contentTemplate3}/>
</TabItemsDirective>
</TabComponent>
</div>);
} |
|
// bind the destroy event for the component in the content
function contentTemplate3() {
return (<ToolbarComponent ref={(toolbar) => { this.toolbarObj = toolbar }} id="toolbar" destroyed={this.ondestroy} >
<ItemsDirective>
.
</ItemsDirective>
</ToolbarComponent>);
}
return (<div className='control-pane'>
<button className="e-control e-btn" onClick={this.buttonClick.bind(this)} id="targetButton" role="button">Click to remove tab</button>
//use the Removing Event for Tab
<TabComponent ref={(tab) => { this.tabObj = tab }} heightAdjustMode='Auto' id='defaultTab' showCloseButton={true} removing={this.tabOnremove.bind(this)} >
<TabItemsDirective>
<TabItemDirective header={headertext[0]} content={contentTemplate1} />
<TabItemDirective header={headertext[1]} content={contentTemplate2} />
<TabItemDirective header={headertext[2]} content={contentTemplate3.bind(this)} />
</TabItemsDirective>
</TabComponent>
tabOnremove(e) {
// based on the selected index destroy the control in the item manually using the destroy method – this will raise the destroy method
if (e.removedIndex === 2) {
this.toolbarObj.destroy();
}
}
ondestroy() {
alert("destroyed")
}
|