BoldDesk®Customer service software offering ticketing, live chat, and omnichannel support, starting at $49/mo. for 10 agents. Try it for free.
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.DataSource).Toolbar(new List<string>() { "Search" }).Columns(col =>
{
. . .
}).DataBound("dataBound").AllowPaging().Render()
<script>
function dataBound(e) {
var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];
// checks whether the cancel icon is already present or not
if (!grid.element.getElementsByClassName('e-search')[0].classList.contains('clear')) {
var span = ej.base.createElement('span', {
id: grid.element.id + '_searchcancelbutton',
className: 'e-clear-icon'
});
span.addEventListener('click', (args) => {
document.querySelector('.e-search').getElementsByTagName('input')[0] = "";
grid.search("");
});
grid.element.getElementsByClassName('e-search')[0].appendChild(span);
grid.element.getElementsByClassName('e-search')[0].classList.add('clear');
}
}
</script> |