Bryan Gomez

Bryan Gomez

  • NA
  • 21
  • 36.8k

Filter table based from dropdown - dataset

Nov 27 2017 12:37 AM
I have a partialview for my table, I want that every time the dropdown is changed the table will refresh acording to the dataset record. But having an error of 
  1. Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help http://xhr.spec.whatwg.org/ 
It appears when I added this script:
  1. $("#txtCategory").change(function () {  
  2.     var value = (this).value  
  3.     $("#tblAssessment").load('@Url.Action("getcategory", "assessment")/' + value);  
  4.   
  5. }); 
In my controller assessment:
  1.     public ActionResult GetCategory(string ID)  
  2.     {  
  3.         dynamic model = new ExpandoObject();  
  4.         var serviceentry = new wmssoft_srm.Models.ServiceEntryFields();  
  5.         model = serviceentry;  
  6.  
  7.         #region "getqacategory"  
  8.         model.GetQA = GetQACategory(ID);  
  9.         #endregion  
  10.   
  11.         return View("_assessment", model);  
  12.     }  
  13.   
  14.     private List<wmssoft_srm.Models.ServiceQACategory> GetQACategory(string category = "")  
  15.     {  
  16.         WMSSOFT_WCF_Service.WMSSOFT_InterfaceClient wmsSR = new WMSSOFT_WCF_Service.WMSSOFT_InterfaceClient();  
  17.         DataSet dsl = new DataSet();  
  18.         DataSet dsO = new DataSet();  
  19.         string a = "ValidateCredentials";  
  20.         string b = category.ToString() + "~~";  
  21.   
  22.         //b = wmsSR.fCallWMSSOFTService(a, null, ref dsl, ref dsO);  
  23.         b = wmsSR.fCallWMSSOFTService("GetSRMQuestionsByCategory", b, ref dsl, ref dsO);  
  24.   
  25.         if (b == "OK ~~")  
  26.         {  
  27.             if (dsO.Tables[0].Rows.Count >= 0)  
  28.             {  
  29.                 DataTable oDT = new DataTable();  
  30.                 oDT = dsO.Tables[0];  
  31.   
  32.                 wmssoft_srm.Models.ServiceEntry slData = new Models.ServiceEntry();  
  33.                 var myList = slData.GetQACategory(oDT);  
  34.   
  35.                 return myList;  
  36.             }  
  37.         }  
  38.         return null;  
  39.     }           
  40.   

 And for my Model:
 
  1.     public List<ServiceQACategory> GetQACategory(DataTable oDT)  
  2.     {  
  3.         List<ServiceQACategory> slData = new List<ServiceQACategory>();  
  4.         for (int i = 0; i < oDT.Rows.Count; i++)  
  5.         {  
  6.             ServiceQACategory sl = new ServiceQACategory();  
  7.   
  8.             sl.questionId = Convert.ToInt32(oDT.Rows[i]["QID"].ToString().Trim());  
  9.             sl.question = oDT.Rows[i]["QUESTION"].ToString().Trim();  
  10.   
  11.             slData.Add(sl);  
  12.         }  
  13.   
  14.         return slData;  
  15.     }  
  16.   
  17. }  
  18.   
  19. public class ServiceQACategory  
  20. {  
  21.     public int questionId { getset; }  
  22.     public string question { getset; }  

 
 Thanks
 

Answers (1)