I am using MVC3 and combobox
my cshtml is
<script type="text/javascript">
$('#c_MENU_ID').combobox({
url: '@Url.Action("GetMenu","Menu")'
});
</script>
and action is
public JsonResult GetFatherMenu()
{
var q = from e in db.MENUS_V
where e.MENU_ID > 0
select new
{
menu_id = e.MENU_ID,
menu_name = e.MENU_NAME
};
var result = q.ToList();
Dictionary<string, object> json = new Dictionary<string, object>();
json.Add("total", q.ToList().Count);
json.Add("rows", result);
return Json(json, JsonRequestBehavior.AllowGet);
}
Now i know that the combo box only accept
[{
"MENU_ID":1,
"MENU_NAME":"text1"
},{
"MENU_ID":2,
"MENU_NAME":"text2"
}]
not{"rows":
[{
"MENU_ID":1,
"MENU_NAME":"text1"
},{
"MENU_ID":2,
"MENU_NAME":"text2"
}]
}
what can i do in the action to return the correct json? Thanks