|
<div>
<ejs-dropdownlist id="id" dataSource="ViewBag.data" value="3" placeholder="Select an ID" popupHeight="220px">
</ejs-dropdownlist>
<ejs-grid id="Grid" dataSource="ViewBag.datasource" load="load" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="120"></e-grid-column>
<e-grid-column field="EmployeeID" headerText="Empolyee Name" foreignKeyValue="FirstName" width="150"></e-grid-column>
. . .
</e-grid-columns>
</ejs-grid>
</div>
<script type="text/javascript">
function load(args) {
var data = new ej.data.DataManager({
url: '/Home/UrlDataSource',
adaptor: new ej.data.UrlAdaptor
});
this.getColumns()[1].dataSource = data;
this.columns[1].edit = {
create: function () {
var ddl = document.querySelector('#id').ej2_instances[0];
var id = ddl.value;
if (id != null) {
this.params.query = new ej.data.Query().addParams('Id', id);
}
countryElem = document.createElement('input');
return countryElem;
}
}
}
</script> |
|
|
That's great news! However, it already works in the sample you provided...
After some more time, I was able to get it working with the sample you provided.
I needed to change the following things:
function load(args) {
...
//add the parameter for the initial load
this.getColumns()[1].query = new ej.data.Query().addParams('id', parseInt(id));
...
}
I needed to add the "ActionBegin" event of the grid to add the parameter when the grid refreshes once the dropdown is changed.
function onActionBegin(args) {
if (args.requestType === "refresh") {
var grid = document.querySelector('#Grid').ej2_instances[0];
grid.getColumns()[1].query = new ej.data.Query().addParams('id', parseInt(document.querySelector('#id').ej2_instances[0].value));
}
}
On the server side the parameter was received and I could use it to filter the employees.
As my (attached) sample shows, this works perfectly fine, so it seems that this feature is already implemented?
However, in my application this does not work at all.
I do the same things to add the parameter, but the server never receives it, it is always null.
BUT when I add the parameter in the "create" function of the column, the server does receive it.
At first I thought that might be because your sample uses an older version of syncfusion (16.1.0.24) but even after upgrading it to the latest version (16.1.0.37) it still worked fine.
In my application my grid uses a custom UrlAdaptor but I guess this should not influence the column?
So now my requirement could be achieved in your sample, but in my application it does not work.
Do you have any ideo why this behavior could occur?