<div class="ctrllabel">
Select a car
</div>
@Html.EJ().DropDownList("selectCar").TargetID("carsList").Width("150px").ClientSideEvents(e => e.Change("change"))
...
</div>
@(Html.EJ().Grid<object>("Grid")
.AllowPaging()
.Columns(col =>
{
...
})
)
<script type="text/javascript">
function change(args) {
if (args.itemId == 1) {
var data = ej.DataManager({ url: "/Home/Event", adaptor: "UrlAdaptor" });
$("#Grid").ejGrid({
dataSource: data,
query: new ej.Query().addParams("employeeID", 4)
});
}
if (args.itemId == 0) {
var data = ej.DataManager({ url: "/Home/Event", adaptor: "UrlAdaptor" });
$("#Grid").ejGrid({
dataSource: data,
query: new ej.Query().addParams("employeeID", 2)
});
}
}
</script>
[Controller.cs]
public ActionResult Event(DataManager dm, int? employeeID)
{
var DataSource = OrderRepository.GetAllRecords();
DataSource = OrderRepository.GetAllRecords().Where(e => e.EmployeeID == employeeID).ToList();
DataResult result = new DataResult();
result.result = DataSource.Skip(dm.Skip).Take(dm.Take).ToList();
result.count = DataSource.Count();
return Json(result, JsonRequestBehavior.AllowGet);
}
|
[View]
<form id="myform">
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
<input type="submit" value="Submit">
</form>
<div id="ControlRegion">
@(Html.EJ().Grid<object>("FlatGrid")
.AllowPaging() /*Paging Enabled*/
.Columns(col =>
{
col.Field("EmployeeID").HeaderText("Employee ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
col.Field("FirstName").HeaderText("First Name").Width(100).Add();
col.Field("Title").Width(120).Add();
col.Field("City").Width(100).Add();
col.Field("Country").Width(100).Add();
}))
</div>
<script>
$("#myform").submit(function (e) {
var dataManager = ej.DataManager({ url: "Grid/Data", adaptor: new ej.UrlAdaptor() });
var form = $(this).serialize();
$("#FlatGrid").ejGrid({
dataSource: dataManager,
query: new ej.Query().addParams("a", form)
});
})
</script>
[controller]
public ActionResult Data(DataManager dm, string a)
{
// do your action here
return View();
}
}
|
[View]
<form id="myform">
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
<input type="submit" value="Submit">
</form>
<div id="ControlRegion">
@(Html.EJ().Grid<object>("FlatGrid")
.AllowPaging() /*Paging Enabled*/
.Columns(col =>
{
col.Field("EmployeeID").HeaderText("Employee ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
col.Field("FirstName").HeaderText("First Name").Width(100).Add();
col.Field("Title").Width(120).Add();
col.Field("City").Width(100).Add();
col.Field("Country").Width(100).Add();
}))
</div>
<script>
$("#myform").submit(function (e) {
var dataManager = ej.DataManager({ url: "Grid/Data", adaptor: new ej.UrlAdaptor() });
var form = $(this).serialize();
$("#FlatGrid").ejGrid({
dataSource: dataManager,
query: new ej.Query().addParams("a", form)
});
})
</script>
[controller]
public ActionResult Data(DataManager dm, string a)
{
// do your action here
return View();
}
}
|
public ActionResult Event(DataManager dm, string a)
{
string responseString = a;
var dict = HttpUtility.ParseQueryString(responseString);
string json = JsonConvert.SerializeObject(dict.Cast<string>().ToDictionary(k => k, v => dict[v]));
var respObj = JsonConvert.DeserializeObject<object>(json);
} |