public JsonResult Search2(string term) { try { term = term.Trim(); var items = ProductAccessorieManager.GetAll(); if (!string.IsNullOrEmpty(term)) { items = ProductAccessorieManager.GetBySearch(term); } return(Json(items.Select(m => m.sDescription), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
//input jquery มันจะ pass parameter ด้วยตัว q เท่านั้น public JsonResult Search(string q) { try { q = q.Trim(); var items = ProductAccessorieManager.GetAll(); if (!string.IsNullOrEmpty(q)) { items = ProductAccessorieManager.GetBySearch(q); } return(Json(items.Select(m => new { name = m.sDescription, id = m.kProductAccessorieId }) , JsonRequestBehavior.AllowGet)); //return Json(items.Select(m => new { name = m.sDescription, id = m.sDescription }) // , JsonRequestBehavior.AllowGet); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }