[index.js]
render() {
// tab items are defined in render
function template1() {
return(
<div>TEXT</div>
);
}
function template2() {
return(
<div className="col-xs-12">
<GridComponent dataSource={employeeData} childGrid = {this.detailGrid} width='auto'>
<ColumnsDirective>
<ColumnDirective field='FirstName' headerText='First Name' isPrimaryKey={true} width='110'/>
<ColumnDirective field='LastName' headerText='Last Name' width='110'/>
<ColumnDirective field='Title' headerText='Name' width='150'/>
<ColumnDirective field='Country' headerText='Country' width='110'/>
</ColumnsDirective>
<Inject services={[DetailRow]}/>
</GridComponent>
</div>
);
}
var headertext;
headertext = [{ text: "Sequence Usage" }, { text: "Measure Tolerances" }];
return (
<DialogComponent height={1000} width="90%" showCloseIcon={true} isModal={true} header={"Edit Tolerance for measure: "}
ref={d => this.dialog = d} allowDragging={true} >
<div className='control-pane'>
<div className='control-section tab-control-section row'>
<div className='col-lg-8'>
{/* Render the Tab Component */}
<TabComponent ref={(tab) => { this.tabObj = tab }} showCloseButton={ true } heightAdjustMode='None' height={320}>
<TabItemsDirective>
<TabItemDirective header={headertext[0]} content={ template1.bind(this) } /> // Bind the tab items through function
<TabItemDirective header={headertext[1]} content={ template2.bind(this) }/>
</TabItemsDirective>
</TabComponent>
</div>
</div>
</div>
</DialogComponent> |
[index.tsx]
class App extends React.Component {
constructor() {
super(...arguments);
this.data = [
{ FirstName: "Ram", LastName: "Kumar", Name: "AJAI", Country: "India" }
];
this.state = { name: "name", family: "family" };
this.headertext = [{ text: "Tab1", iconCss: "e-twitter" }];
}
tabContent = (data, data1) => {
return (
<React.Fragment>
{console.log("--->tabContent1: Name=", this.state.name)}
<p>Grid control is rendered inside Tab Component</p>
<div>
<GridComponent dataSource={this.data} width="auto">
<ColumnsDirective>
<ColumnDirective
field="FirstName"
headerText="First Name"
isPrimaryKey={true}
width="110"
/>
<ColumnDirective
field="LastName"
headerText="Last Name"
width="110"
/>
<ColumnDirective field="Title" headerText="Name" width="150" />
<ColumnDirective
field="Country"
headerText="Country"
width="110"
/>
</ColumnsDirective>
<Inject services={[DetailRow]} />
</GridComponent>
<p>{data.text}</p> // state value changed here when update the state value in button click action
<p>{data.textVal}</p> // state value changed here when update the state value in button click action
<button onClick={this.btnClick.bind(this)}>click hear</button>
</div>
</React.Fragment>
);
};
btnClick = () => {
var newName = "name :" + new Date().toTimeString();
var familyName = "family : " + new Date().toTimeString();
this.setState({ name: newName });
this.setState({ family: familyName });
};
ShowTabs = () => {
return (
<TabComponent
enablePersistence="true"
heightAdjustMode="Auto"
id="defaultTab" >
<TabItemsDirective>
<TabItemDirective
presentation={true}
header={this.headertext[0]}
content={{
template: this.tabContent,
data: { text: this.state.name, textval: this.state.family } //Pass the state values in data property in tab component
}}
/>
{console.log("ShowTabs2")}
</TabItemsDirective>
</TabComponent>
);
};
render() {
return (
<div className="control-pane">
<div className="control-section tab-control-section">
<button onClick={this.btnClick.bind(this)}>click here</button>
<br />
{this.ShowTabs()}
</div>
</div>
);
}
}
render(<App />, document.getElementById("root")); |
Hi Matteo,
We have checked the previously updated the sample. It is working properly with your requirement. We are prepared a video with explained state property behavior on Tab component with EJ2 Grid. Please refer the sample and Video demonstration for more information.
Sample link: https://codesandbox.io/s/confident-booth-ocxxc
Regards,Thavasianand S.
Hi Matteo,We have checked the provided code example and prepared the sample for validate the TextBox and DropDownList component in different tab inside the Dialog component and attached below.Please check the above sample and explain the issue that you have faced in your application (which components) by any screenshot or video demonstration that will help us to check and proceed further.Also, we have updated the value field to the component using state programmatically.Regards,Sureshkumar P
<TabItemDirective connectStatus={this.state.connectionFromStore}
header={this.tabHeaders[0]}
content={this.connectionTabContent}
/>
|
Hi Matteo,he content template components have not refreshed since we have rendered the template components as individual react component and we only update the components if we detect any changes in the component properties to avoid multiple rerender of the components, so we suggest you assign a state property in the TabItemDirective to trigger the state changes
<TabItemDirective connectStatus={this.state.connectionFromStore}header={this.tabHeaders[0]}content={this.connectionTabContent}/>We have also prepared a sample for content changes in tab on state change. Please find the sample link in below:Regards,Sureshkumar P
<div className="row">
<div className="col-sm-6">
<TextBoxComponent placeholder="Italian"
floatLabelType="Auto"
id="Italian_textbox"
value={connection.host} ref={textbox =>
this.italianObj = textbox}
/>
</div>
<button id="Italian_button" className="e-btn" onClick={this.ItalianChange.bind(this)}>Copy Italian</button>
</div>
ItalianChange = () => {
this.frenchObj.value = this.italianObj.value;
this.germanObj.value = this.italianObj.value;
this.englishObj.value = this.italianObj.value;
} |
Hi Matteo,
We have integrated the Form Validator with the requested requirement inside the Tab component and attached it below.
Please find the sample from the below link.Regards,Berly B.C
<form id="form1">
<div className="form-horizontal mt-3">
<div className="row">
<div className="col-sm-6">
<TextBoxComponent placeholder="Italian" floatLabelType="Auto" id="Italian_textbox" name="Italian"
change={this.textboxChange.bind(this)} value={connection.host} ref={textbox=> this.italianObj =
textbox}
/>
</div>
<button id="Italian_button" type="button" className="e-btn" onClick={this.ItalianChange.bind(this)}>Copy
Italian</button>
</div>
<div className="row">
<div className="col-sm-6">
<TextBoxComponent placeholder="French" name="French" floatLabelType="Auto" id="French_textbox"
change={this.textboxChange.bind(this)} value={connection.port} ref={textbox=> this.frenchObj =
textbox}
/>
</div>
<button id="French_button" type="button" className="e-btn" onClick={this.FrenchChange.bind(this)}>Copy
French</button>
</div>
<div className="row">
<div className="col-sm-6">
<TextBoxComponent placeholder="German" name="German" floatLabelType="Auto" id="German_textbox"
change={this.textboxChange.bind(this)} value={connection.port} ref={textbox=> this.germanObj =
textbox}
/>
</div>
<button id="German_button" type="button" className="e-btn" onClick={this.GermanChange.bind(this)}>Copy
German</button>
</div>
<div className="row">
<div className="col-sm-6">
<TextBoxComponent placeholder="English" name="English" floatLabelType="Auto" id="English_textbox"
change={this.textboxChange.bind(this)} value={connection.port} ref={textbox=> this.englishObj =
textbox}
/>
</div>
<button id="English_button" type="button" className="e-btn" onClick={this.EnglishChange.bind(this)}>Copy
English</button>
</div>
</div>
<div className="row mt-5">
<div className="col-sm-4 btn-group">
<div className="pl-2"></div>
</div>
</div>
</form>
|