| <ejs-grid actionComplete="complete" dataBound="dataBound" id="Grid" dataSource="ViewBag.datasource" allowPaging="true" toolbar="@(new List<string>() { "Add","Edit", "Delete", "Update", "Cancel", "dropdown" })" height="270"> <e-grid-columns> . . . </e-grid-columns> </ejs-grid> <script> var data = ['Normal', 'Dialog', 'Batch']; var dropDownListObject; var grid; function dataBound() { var list = document.getElementsByClassName("e-toolbar-item")[5]; . . . var input = ej.base.createElement('input', { id: 'ddl' }); list.appendChild(input); dropDownListObject = new ej.dropdowns.DropDownList({ // set the data to dataSource property dataSource: data, value: grid.editSettings.mode, change: change, popupHeight: 200 }); dropDownListObject.appendTo('#ddl'); } function change(args) { grid.editSettings.mode = args.value; } </script> |
| <script> function dataBound() { grid = document.getElementById("entityGrid").ej2_instances[0]; // Getting EJ2 Grid instance if (ej.base.isNullOrUndefined(grid.toolbarModule.element.querySelector('#ddl'))) { // checking whether the dropdown is already present or not var list = document.getElementsByClassName("e-toolbar-item")[5]; list.removeChild(list.childNodes[0]); // removes the temporary toolbar item var input = ej.base.createElement('input', { id: 'ddl' }); list.appendChild(input); // appends the new input element in the toolbar dropDownListObject = new ej.dropdowns.DropDownList({ // set the data to dataSource property dataSource: data, value: grid.editSettings.mode, change: change, popupHeight: 200 }); dropDownListObject.appendTo('#ddl'); // appends the dropdown component in the input element } } function change(args) { grid.editSettings.mode = args.value; // changing the editSettings mode } </script> <div> <ejs-grid id="entityGrid" dataBound="dataBound" columns="@ViewData["columns"]" toolbar="@(new List<string>() { "Add","Edit", "Delete", "Update", "Cancel", "dropdown" })" allowPaging="true" allowSelection="true" allowSorting="true" allowFiltering="true" > <e-data-manager url="/Home/UrlDatasource" adaptor="UrlAdaptor" BatchUrl="/Home/Update"></e-data-manager> <e-grid-editSettings allowEditing="true" allowAdding="true" allowDeleting="true" mode="Dialog"></e-grid-editSettings> <e-grid-pagesettings pageCount="5" pageSize="15" pageSizes="@(new string[] { "5", "10", "15", "20", "25", "50", "All" })"></e-grid-pagesettings> <e-grid-filterSettings type="Menu" mode="OnEnter" showFilterBarStatus="true"></e-grid-filterSettings> <e-grid-sortSettings></e-grid-sortSettings> </ejs-grid> <ejs-scripts></ejs-scripts> </div> |
<div tabindex="0" class="e-control e-toolbar e-keyboard" id="entityGrid_toolbarItems" role="toolbar" aria-disabled="false" aria-haspopup="false" style="width: auto; height: auto;" aria-orientation="horizontal">
<div class="e-toolbar-items">
<div title="Add" class="e-toolbar-item" aria-disabled="false"><button tabindex="-1" class="e-tbar-btn e-tbtn-txt e-control e-btn" id="entityGrid_add" style="width: auto;" type="button"><span class="e-btn-icon e-add e-icons e-icon-left"></span><div class="e-tbar-btn-text">Add</div></button></div>
<div title="Edit" class="e-toolbar-item" aria-disabled="false"><button tabindex="-1" class="e-tbar-btn e-tbtn-txt e-control e-btn" id="entityGrid_edit" style="width: auto;" type="button"><span class="e-btn-icon e-edit e-icons e-icon-left"></span><div class="e-tbar-btn-text">Edit</div></button></div>
<div title="Delete" class="e-toolbar-item" aria-disabled="false"><button tabindex="-1" class="e-tbar-btn e-tbtn-txt e-control e-btn" id="entityGrid_delete" style="width: auto;" type="button"><span class="e-btn-icon e-delete e-icons e-icon-left"></span><div class="e-tbar-btn-text">Delete</div></button></div>
<div title="Update" class="e-toolbar-item e-overlay" aria-disabled="true"><button tabindex="-1" class="e-tbar-btn e-tbtn-txt e-control e-btn" id="entityGrid_update" style="width: auto;" type="button"><span class="e-btn-icon e-update e-icons e-icon-left"></span><div class="e-tbar-btn-text">Update</div></button></div>
<div title="Cancel" class="e-toolbar-item e-overlay" aria-disabled="true"><button tabindex="-1" class="e-tbar-btn e-tbtn-txt e-control e-btn" id="entityGrid_cancel" style="width: auto;" type="button"><span class="e-btn-icon e-cancel e-icons e-icon-left"></span><div class="e-tbar-btn-text">Cancel</div></button></div>
<div class="e-toolbar-item" aria-disabled="false">
<button tabindex="-1" class="e-tbar-btn e-tbtn-txt e-control e-btn" id="entityGrid_dropdown" style="width: auto;" type="button">
<div class="e-tbar-btn-text">dropdown</div>
</button>
</div>
</div>
</div>
var list = document.getElementsByClassName("e-toolbar-item")[5];
<script>
// creates dropdown in Grid toolbar so that user can select an Edit mode
var grid;
function dataBound() {
grid = document.getElementById("entityGrid").ej2_instances[0];
if (ej.base.isNullOrUndefined(grid.toolbarModule.element.querySelector('#ddl'))) { // checking whether the dropdown is already present or not
var data = ['Normal', 'Dialog', 'Batch'];
var dropDownListObject;
var list = document.getElementsByClassName("e-toolbar-item")[5];
list.removeChild(list.childNodes[0]); // removes the temporary toolbar item
var input = ej.base.createElement('input', { id: 'ddl' });
list.appendChild(input);
dropDownListObject = new ej.dropdowns.DropDownList({
// set the data to dataSource property
dataSource: data,
value: grid.editSettings.mode,
change: changeEditMode,
popupHeight: 200
});
dropDownListObject.appendTo('#ddl');
}
}
function changeEditMode(args) {
grid.editSettings.mode = args.value;
}
</script>
<div><ejs-grid id="entityGrid" columns="@ViewData["columns"]" toolbar="@(new List<string>() { "Add","Edit", "Delete", "Update", "Cancel", "dropdown" })" allowPaging="true" allowSelection="true" allowSorting="true" allowFiltering="true" query="new ej.data.Query().addParams('CatalogGuid', '@ViewData["catalogGuid"]').addParams('EntityGuid', '@ViewData["entityGuid"]')">...
| <script> function dataBound() { grid = document.getElementById("entityGrid").ej2_instances[0]; if (ej.base.isNullOrUndefined(grid.toolbarModule.element.querySelector('#ddl'))) { var list = document.getElementsByClassName("e-toolbar-item")[5]; list.removeChild(list.childNodes[0]); var input = ej.base.createElement('input', { id: 'ddl' }); var span = ej.base.createElement('span', { className: 'e-btn-icon e-add e-icons e-icon-left' }); var label = ej.base.createElement('div', { className: 'e-tbar-btn-text', innerHTML:'EditMode' }); list.appendChild(input); list.appendChild(span); // appending the span element for icon next to dropdown component list.appendChild(label); // appending the div element for label dropDownListObject = new ej.dropdowns.DropDownList({ . . . }); dropDownListObject.appendTo('#ddl'); } } </script> <div> <ejs-grid id="entityGrid" dataBound="dataBound" columns="@ViewData["columns"]" toolbar="@(new List<string>() { "Add","Edit", "Delete", "Update", "Cancel", "dropdown" })" allowPaging="true" allowSelection="true" allowSorting="true" allowFiltering="true" > . . . </ejs-grid> <ejs-scripts></ejs-scripts> </div> |