|
App.Component.html
<ejs-toolbar (created)="onCreate($event)">
<e-items>
<e-item template='<input type="text" tabindex="1" id="dpelement" />' type='Input' align='Left'>
</e-item>
<e-item template='<input type="text" tabindex="1" id="inputelement" />' type='Input' align='Right'>
</e-item>
</e-items>
</ejs-toolbar>
<ejs-treegrid #treegrid [dataSource]='data' height='350' allowPaging='true' [pageSettings]='pageSettings'
childMapping='subtasks' [treeColumnIndex]='1' allowFiltering='true'>
<e-columns>
<e-column field='taskID' headerText='Task ID' width='80' textAlign='Right'></e-column>
. . .
</e-columns>
</ejs-treegrid>
App.Component.ts
export class AppComponent {
public searchInput: any = new TextBox({
placeholder: "Search",
change: args => {
this.treegrid.search(args.value); //perform search action using Search method
}
});
public datePicker: any = new DatePicker({
placeholder: "Sub filter: Start Date",
change: e => {
this.treegrid.filterByColumn("startDate", "equal", e.value); //using filterByColumn method perform Filtering on datePicker
}
});
public onCreate(e: any) {
this.searchInput.appendTo("#inputelement");
this.datePicker.appendTo("#dpelement");
}
} |
|
App.Component.html
<ejs-toolbar (created)="onCreate($event)">
<e-items>
<e-item template=' <input type="text" tabindex="1" id="comboelement"/>' type='Input' align='Left'>
</e-item>
. . .
</e-items>
</ejs-toolbar>
App.Component.ts
export class AppComponent {
public data: Object[] = [];
public taskData: { [key: string]: Object }[] = [
{ Id: "1", TaskName: "Planning" },
{ Id: "2", TaskName: "Plan timeline" },
{ Id: "3", TaskName: "Design" }
];
public Combobox: any = new ComboBox({
//set the data to dataSource property
dataSource: this.taskData,
change: args => {
var val = args.value;
if (!isNullOrUndefined(val)) {
this.treegrid.filterByColumn("taskName", "equal", val);
} else this.treegrid.clearFiltering();
},
// use text and Value with name value
fields: { text: "TaskName", value: "TaskName" },
// set placeholder to ComboBox input element
placeholder: "Select a task"
});
|
|
export class AppComponent {
@ViewChild("treegrid") public treegrid: TreeGridComponent;
public data: Object[] = [];
public taskData = [
{ Id: "1", Priority: "Normal" },
{ Id: "2", Priority: "Low" },
{ Id: "3", Priority: "High" }
];
public Combobox: any = new ComboBox({
//set the data to dataSource property
dataSource: this.taskData,
change: args => {
var val = args.value;
if (!isNullOrUndefined(val)) {
var value = parseInt(this.taskData.filter(data => data.Priority === val)[0].Id)
this.treegrid.filterByColumn("priority", "equal", value);
} else this.treegrid.clearFiltering();
},
// maps the appropriate column to fields property
fields: { text: "Priority", value: "Priority" },
// set placeholder to ComboBox input element
placeholder: "Select a task"
});
private createTreeGridColumns() {
return [
{ field: "taskID", headerText: "Task ID", editType: "defaultedit" },
{ field: "startDate", headerText: "Start Date", editType: "defaultedit" },
{
field: "priority", //use Field which is present in TreeGrid dataSource
headerText: "Priority",
valueAccessor: ((field, data, column) => {
if (data.priority !== "Critical") {
const mcref = this.taskData.find(
td => td.Id === data.priority.toString()
);
console.log(mcref);
return mcref ? mcref.Priority : "";
}
}).bind(this),
editType: "dropdownedit",
edit: {
params: {
query: null,
dataSource: this.taskData,
fields: { value: "Id", text: "Priority" }
}
}
},
}
];
</script> |