// external search box
<input id="ext_search" />
<button id="Search_button" onclick="searching(this)" >Search</button>
<button id="clear_button" onclick="clearing(this)">Clear</button>
<ejs-grid id="Grid" dataSource=@ViewBag.data width="auto">
<e-grid-columns>
<e-grid-column field="EmployeeID" headerText="Employee ID" textAlign="Right" width="125"></e-grid-column>
<e-grid-column field="OrderID" headerText="Order ID" width="120"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer ID" width="170"></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script>
function searching(e) {
var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];
var value = document.getElementById("ext_search").value;
grid.search(value); // search the textbox value
}
function clearing(e) {
var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];
document.getElementById("ext_search").value = "";
grid.search(""); // clears the searching
}
</script> |
<script>
function searching(e) {
var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];
for (var i = 0; i < document.getElementsByTagName("input").length; i++) {
grid.filterByColumn(grid.columns[i].field, "contains", document.getElementsByTagName("input")[i].value)// filter the textbox value
}
}
function clearing(e) {
var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];
document.getElementById("emp_search").value = "";
document.getElementById("ord_search").value = "";
document.getElementById("cust_search").value = "";
grid.clearFiltering(); // clears the filtering
}
</script>
|