<ejs-grid id="Grid" allowPaging="true" actionBegin="actionBegin" toolbar="@(new List<string>() {"Add", "Edit", "Update", "Delete", "Search" })">
. . . . . . . .
</ejs-grid>
<script>
var SearchValue;
function actionBegin(args) {
if (args.requestType === 'searching') {
SearchValue = args.searchString;
var ajax = new ej.base.Ajax({
type: "POST",
url: "/Home/SelectRecord",
contentType: "application/json; charset=utf-8",
});
var data = JSON.stringify({ FilteredValue: SearchValue });
ajax.send(data).then();
ajax.onSuccess = result => {
};
}
}
<script>
public ActionResult SelectRecord([FromBody]SelectedModel row)
{
//perfoerm your action here as per your needs.
return Json(row);
}
public class SelectedModel
{
public string FilteredValue { get; set; }
} |
[index.cshtml]
<ejs-grid id="Grid" allowPaging="true" detailDataBound="detailDataBound" toolbar="@(new List<string>() {"Add", "Edit","Update", "Delete", "Search" })">
. . . . . . . .
</ejs-grid>
function detailDataBound (args) {
var grid = document.getElementById("Grid").ej2_instances[0];
var currentRow = args.detailElement.parentElement.previousElementSibling;
var currentRowIndex = parseInt(
currentRow.getAttribute("aria-rowindex"),
10
);
var expandedRows = grid.element.querySelectorAll(".e-detailrowexpand");
[].slice.call(expandedRows).forEach(item => {
var row = item.parentElement;
var index = parseInt(row.getAttribute("aria-rowindex"), 10);
if (currentRowIndex != index) {
grid.detailRowModule.collapse(index);
}
});
}, |