|
<input type="text" value=10258 id="textbox" />
<ej-grid id="Grid" datasource=ViewBag.orderdata is-responsive="true" allow-filtering="true" enable-responsive-row="true" allow-scrolling="true" allow-paging="true" >
<e-columns>
<e-column field="EmployeeID" is-primary-key="true" header-text="EmployeeID" text-align="Right" width="30"></e-column>
<e-column field="CustomerID" header-text="Title" width="80"></e-column>
</e-columns>
<ej-grid query-string="EmployeeID" allow-paging="true" allow-filtering="true" load="Load">
<e-datamanager json="(IEnumerable<object>)ViewBag.empdata" adaptor="remoteSaveAdaptor"></e-datamanager>
<e-columns>
<e-column field="OrderID" header-text="Employee ID" text-align="Right" width="75"></e-column>
. . .
</e-columns>
</ej-grid>
</ej-grid>
<script>
function Load(args) {
var textboxValue = $("#textbox").val();//get the value from text box which is resides in outside of the Grid
this.model.filterSettings.filteredColumns.push({ field: "OrderID", operator: "equal", value: textboxValue }); //apply the filter in filtered column property
}
</script> |
querystring is a property that has to be specified within the Grid within the Grid, which defines the relation between the parent and child grid. The querystring property is used to denote the primaryKey field of the parent grid which is to be mapped with the foreignKey field of the child grid. Based on the mapping, the child grid records are filtered from the table and is bound as datasource for the child grid. |
<input type="button" value="clearFilter" onclick="myFunction()" />
$(function () {
<ej-grid id="Grid" datasource=ViewBag.orderdata is-responsive="true" allow-filtering="true" enable-responsive-row="true" allow-scrolling="true" allow-paging="true" >
<e-columns>
<e-column field="EmployeeID" is-primary-key="true" header-text="EmployeeID" text-align="Right" width="30"></e-column>
. .
</e-columns>
<ej-grid query-string="EmployeeID" allow-paging="true" allow-filtering="true" load="Load">
<e-datamanager json="(IEnumerable<object>)ViewBag.empdata" adaptor="remoteSaveAdaptor"></e-datamanager>
<e-columns>
<e-column field="OrderID" header-text="Employee ID" text-align="Right" width="75"></e-column>
. . .
</e-columns>
</ej-grid>
</ej-grid>
<script type="text/javascript">
var id = null;
$(".e-grid").on('click','.e-grid', function(e){
var id = $(e.target).closest('[id]').attr("id");
});
function myFunction(){
var grid = $("#"+id).ejGrid("instance");
grid.clearFiltering();
}
</script> |