|
<script id="employeetemplate" type="text/x-jsrender">
<input id="dropdown1" />
</script>
@(Html.EJ().Grid<Object>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.data)
.AllowPaging()
.ClientSideEvents(eve => { eve.DataBound("dataBound"); })
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").Add();
col.Field("CustomerID").HeaderText("Order ID").Add();
col.Field("EmployeeID")
.HeaderTemplateID("#employeetemplate").Add();
})) <script>
var items = [
{
text: "ListItem 1",
value: "item1"
}, {
text: "ListItem 2",
value: "item2"
},
-------
];
function dataBound(args) {
$('#dropdown1').ejDropDownList({
dataSource: (items),
value: "item1",
change: function (args) {
var data = { "data": args.text };
$.ajax({
url: '/Home/DataSource',
dataType: "json",
contentType: 'application/json; charset=utf-8',
type: 'POST',
data: JSON.stringify(data),
//pass the selectedValue of the dropdown to server side
success: function (data) {
}
})
}
});
}
</script>
in controller end
public ActionResult DataSource(string data)
{
//perform your action
return Json(data);
} |