I have Kendo Grid and a ForeignKey column on a page. ForeignKey column is populated using ViewData as described below.
column.ForeignKey(x => x.ProductID, (List<Product>)ViewData["products"], "ID", "ProdName");
The Grid is editable in batch(InCell) mode as show below…
.Editable(editable => editable.Mode(GridEditMode.InCell)
I want to modify collection of ProductID column in the grid after page is loaded based on value selected on other drop-down defined outside of the Grid.
How can I achieve that? Can I do it using jQuery?
Similar example I found here…
http://www.telerik.com/community/forums/aspnet-mvc/grid/cascading-dropdowns-in-grid-edit—foreignkey-columns.aspx
Thanks.
Best Answer
I figured out how to filter the Product drop-down using an EditorTemplate for the foreign key column.
Here is my column definition for the Product.
Here is the editor template for Product, ProductIDEditor.cshtml
In my main VIEW Index.cshtml, I added
filterProducts
JavaScript handler, that passes JSON object forproductID
to controller.Here is the controller that listens to filtering event...
FilterProducts
will be called every time when user hits the drop-down to get filtered value.