0
如何可以使用類似於下面的代碼東西調用的ViewResult控制器操作/方法從jquery的/ JavaScript的:如何從jquery/javascript中調用MVC3 ViewResult動作?
Index.cshtml(回調多選):
<script type="text/javascript">
$("select").multiselect({
click: function (event, ui) {
// item selected
//
// Also, not sure how I can pass in values from a multiselect to update my grid
// ...using ajax or post???
$.post(
'@Url.Action("Index","Main")');
//, { value: ui.value, state: ui.checked ? 'checked' : 'unchecked' });
// call my index() and get values or pass in values from multiselect
// or...
$.ajax(
{ url: '@Url.Action("Index","Main")'...// }
//, { value: ui.value, state: ui.checked ? 'checked' : 'unchecked' });
// call my index() and get values or pass in values from multiselect
})
}
});
</script>
控制器:
// GET: /Main/
public ViewResult Index(/* not sure if possible */
/* get values from multiselect */
string[] MultiselectId)
{
// Populate default grid view
IList<CModel> cs = db.CModels.OrderByDescending(x => x.CName).ToList();
// get values in #multiselect and filter grid contents based on that filter value
// if a filter was selected...
return View(cs);
}