|
[index.js]
export class Searching extends SampleBase {
constructor() {
super(...arguments);
this.toolbarOptions = [{template:this.temp}];
}
temp(props) {
const items = [
{
item: 'Edit',
iconCss: 'e-icons e-edit'
},
{
item: 'Delete',
iconCss: 'e-icons e-delete'
},
{
item: 'Mark As Read',
iconCss: 'e-icons e-read'
}];
function onChange(args) {
console.log(args)
// write your code here...
}
return (
<DropDownListComponent id="dropdown" dataSource={items} placeholder="Select" fields= { { text: 'item', value: 'item' }} change={onChange}/>);
}
render() {
return (<div className='control-pane'>
<div className='control-section row' >
<GridComponent dataSource={categoryData} toolbar={this.toolbarOptions} allowPaging={true} pageSettings={{ pageSize: 10, pageCount: 5 }}>
<ColumnsDirective>
. . . .
</ColumnsDirective>
<Inject services={[Toolbar, Page]}/>
</GridComponent>
</div>
</div>);
}
}
|
|
export class DialogEdit extends SampleBase {
constructor() {
super(...arguments);
this.toolbarOptions = ['Add', 'Edit', 'Delete'];
this.editSettings = {
allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Dialog',
headerTemplate: '<div>Dialog Header</div>',
};
this.editparams = { params: { popupHeight: '300px' } };
this.validationRules = { required: true };
this.orderidRules = { required: true, number: true };
this.pageSettings = { pageCount: 5 };
}
actionComplete(args) {
if (args.requestType === 'beginEdit' || args.requestType === 'add') {
// here You can customize the footer of the dialog
args.dialog.footerTemplate = "<div>Customized Footer</div>"
}
}
render() {
return (<div className='control-pane'>
<div className='control-section'>
<GridComponent dataSource={data} toolbar={this.toolbarOptions} actionComplete={this.actionComplete.bind(this)}
allowPaging={true} editSettings={this.editSettings} pageSettings={this.pageSettings}>
<ColumnsDirective>
. . .
</ColumnsDirective>
<Inject services={[Page, Toolbar, Edit]}/>
</GridComponent>
</div>
</div>);
}
}
render(<DialogEdit />, document.getElementById('sample')); |
|
[Index.js]
export class DialogTemplate extends SampleBase {
constructor() {
super(...arguments);
this.toolbarOptions = ['Add', 'Edit', 'Delete'];
this.editSettings = { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Dialog', template: this.dialogTemplate };
this.validationRules = { required: true };
this.orderidRules = { required: true, number: true };
}
render() {
return (<div className='control-pane'>
<GridComponent dataSource={orderData} toolbar={this.toolbarOptions} allowPaging={true} editSettings={this.editSettings} pageSettings={this.pageSettings}
actionComplete={this.actionComplete.bind(this)}>
<ColumnsDirective>
<ColumnDirective field='OrderID' headerText='Order ID' width='120' textAlign='Right' validationRules={this.orderidRules} isPrimaryKey={true}></ColumnDirective>
<ColumnDirective field='CustomerName' headerText='Customer Name' width='150' validationRules={this.validationRules}></ColumnDirective>
<ColumnDirective field='Freight' headerText='Freight' width='120' format='C2' textAlign='Right'></ColumnDirective>
<ColumnDirective field='OrderDate' headerText='Order Date' format='yMd' width='170' ></ColumnDirective>
<ColumnDirective field='ShipCountry' headerText='Ship Country' width='150' ></ColumnDirective>
</ColumnsDirective>
<Inject services={[Page, Toolbar, Edit]} />
</GridComponent>
</div>);
} |
|
[index.js]
this.isSave = false;
actionBegin(args) {
if (args.requestType == "save" && !this.isSave) {
this.isSave=false;
args.cancel=true; //Prevent the save action
}
}
success(){
// if you get response from the server, call endEdit method to manually save to Grid
this.isSave=true;
this.grid.endEdit();
} |