Hi,
Q1- How to hide "Add" Command from tool bar In Tree Grid?
Q2- How to change row color based on specific value in specific column?
Thank you very much
<button onclick="hideadd()">Hide ADD Option</button>
<button onclick="showadd()">Show ADD Option</button>
<div>
<ejs-treegrid id="TreeGrid" dataSource="@ViewBag.data" allowPaging="true" childMapping="Children" treeColumnIndex="1" toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })">
<e-treegrid-editsettings allowAdding="true" allowEditing="true" allowDeleting="true" newRowPosition="Below"></e-treegrid-editsettings>
<e-treegrid-columns>
<e-treegrid-column field="TaskId" isPrimaryKey="true" headerText="Task ID" textAlign="Right" width="90"></e-treegrid-column>
<e-treegrid-column field="TaskName" headerText="Task Name" width="180"></e-treegrid-column>
<e-treegrid-column field="StartDate" headerText=" Start Date" textAlign="Right"
format="yMd" type="date" width="90"></e-treegrid-column>
<e-treegrid-column field="Duration" headerText="Duration" textAlign="Right" width="80"></e-treegrid-column>
</e-treegrid-columns>
</ejs-treegrid>
</div>
<script>
function hideadd(){
var treeGridObj = document.getElementById("TreeGrid").ej2_instances[0];
treeGridObj.toolbar = ['Delete', 'Update', 'Cancel']; //hides the add button
}
function showadd(){
var treeGridObj = document.getElementById("TreeGrid").ej2_instances[0];
treeGridObj.toolbar = ['Add', 'Delete', 'Update', 'Cancel']; //shows the add button
}
</script>
|
var actions = @Html.Raw(Json.Serialize(ViewBag.currentActions))
function beforeDataBound(args) {
var data = this.toolbar.indexOf('Add');
this.toolbarModule.toolbar.hideItem(data, true);
data = this.toolbar.indexOf('Edit');
this.toolbarModule.toolbar.hideItem(data, true);
data = this.toolbar.indexOf('Delete');
this.toolbarModule.toolbar.hideItem(data, true);
for (var i = 0; i < actions.length; i++) {
if ('Add'== actions[i].Type) {
var data = this.toolbar.indexOf('Add');
this.toolbarModule.toolbar.hideItem(data, false);
}
if ('Edit' == actions[i].Type) {
var data = this.toolbar.indexOf('Edit');
this.toolbarModule.toolbar.hideItem(data, false);
}
if ('Delete' == actions[i].Type) {
var data = this.toolbar.indexOf('Delete');
this.toolbarModule.toolbar.hideItem(data, false);
}
}
}
function beforeDataBound(args) {
var data = this.toolbar.indexOf('Add');
this.toolbarModule.getToolbar().ej2_instances[0].hideItem(data, true);
data = this.toolbar.indexOf('Edit');
this.toolbarModule.getToolbar().ej2_instances[0].hideItem(data, true);
data = this.toolbar.indexOf('Delete');
this.toolbarModule.getToolbar().ej2_instances[0].hideItem(data, true);
for (var i = 0; i < actions.length; i++) {
if ('Add'== actions[i].Type) {
var data = this.toolbar.indexOf('Add');
this.toolbarModule.getToolbar().ej2_instances[0].hideItem(data, false);
}
if ('Edit' == actions[i].Type) {
var data = this.toolbar.indexOf('Edit');
this.toolbarModule.getToolbar().ej2_instances[0].hideItem(data, false);
}
if ('Delete' == actions[i].Type) {
var data = this.toolbar.indexOf('Delete');
this.toolbarModule.getToolbar().ej2_instances[0].hideItem(data, false);
}
}
}
|
Perfect,
Thanks very much to your response