Hello.
I'm developing a small application in Asp.Net Core and using Syncfusion grids.
I have a grid (of Products) with child grid (of product UOM). I have search bar on parent grid which is working fine (on parent grid only).
But i want the search to be perform on both grids. Means if user type a keyword it should search in child grid's datamanager
Also is it possible that if user type a UOM / Price (which exists in child grid) the parent grid
Also is it possible to filter parent grid's rows when user type UOM/Price (which exists in child grid). I mean parent grid datamanager should filtered on behalf of child grid datamanager.
Hope you understand what i mean.
I'm using ODataV4Adapter for both grids.
Here is my Parent Grid:
<ejs-grid id="Grid" load="loadUOM"
allowPaging="true"
allowSorting="true"
allowResizing="true"
allowFiltering="true"
query="new ej.data.Query().expand('Manufacturer($select=Title),Category($select=Title),Group($select=Title)')"
toolbar="@(new List<string>() {"Search" })">
<e-data-manager url="/API/ProductApi" adaptor="ODataV4Adaptor" crossdomain="true"></e-data-manager>
<e-grid-filtersettings type="Menu" columns="filterColumns"></e-grid-filtersettings>
<e-grid-pagesettings pageSize="15"></e-grid-pagesettings>
<e-grid-columns>
<e-grid-column field="Title" headerText="Name/Title" type="string" width="120"></e-grid-column>
<e-grid-column field="Manufacturer.Title" headerText="Manufacturer" type="string" width="140"></e-grid-column>
<e-grid-column field="Group.Title" headerText="Group" width="120" type="string"></e-grid-column>
<e-grid-column field="Category.Title" headerText="Category" width="140" type="string"></e-grid-column>
<e-grid-column field="Size" headerText="Size" type="string" width="80"></e-grid-column>
<e-grid-column field="Color" headerText="Color" type="string" width="80"></e-grid-column>
<e-grid-column headerText="Action" allowFiltering="false" allowSorting="false" allowSearching="false" textAlign="Center" width="50" template="#actionColumnTemplate"></e-grid-column>
</e-grid-columns>
</ejs-grid>
Here is my Child Grid Code:
<script>
function loadUOM(args) {
this.setProperties({
childGrid: {
dataSource: new ej.data.DataManager({
url: "/API/ProductUomApi",
adaptor: new ej.data.ODataV4Adaptor(),
crossDomain: true
}),
queryString: 'ProductId', //queryString value will be same in both parent and child grid dataSource
allowPaging: false,
allowSorting:true,
columns: [
//{ field: 'ProductUOMId', headerText: 'ID', width: 120 },
{ field: 'Code', headerText: 'Code', width: 150 },
{ field: 'Barcode', headerText: 'Barcode', width: 150 },
{ field: 'QtyPerUOM', headerText: 'Qty', textAlign: 'Right', width: 150 },
{ field: 'SalePrice', headerText: 'Sale Price', textAlign: 'Right', width: 150 },
{ field: 'PurchasePrice', headerText: 'Purchase Price', textAlign: 'Right', width: 150 }
],
}
}, true);
}
</script>
here is my Grid Output:
Thanks for your time.
so if parent grid can't be filtered with child grid data.
then can we render both Parent & Child grids with same data source? I mean grid data source return relational data with list of Product and each product having its UOM(s).
Also when we perform a search it will query both parent & child entities
Kindly share some example code (if any).
|
var grid = new ej.grids.Grid({
---------------------------
---------------------------
childGrid: {
dataSource: dataManger,
dataBound: function (args) {
var parentGrid = document.getElementById(this.parentDetails.parentID)
.ej2_instances[0];
this.searchSettings = { key: parentGrid.searchSettings.key };
},
allowSearching: true,
queryString: 'EmployeeID',
allowPaging: true,
toolbar: ['Search'],
----------------------------------
----------------------------------
},
});
grid.appendTo('#Grid');
|