Skip to content
Loading
  1. "text/javascript">  
  2.     $(function () {  
  3.         $('#ShipmentItemList').DataTable({  
  4.             "ajax": "@Url.Action("getshipmentitemlist", "shipment")?shipmentId=" + @ViewBag.ShipmentId,  
  5.             "columns": [  
  6.                 { "data": "ShipmentName" },  
  7.                 { "data": "PackageNumber" },  
  8.                 { "data": "TrackingNumber" },  
  9.                 { "data": "ClientName" },  
  10.                 { "data": "Status" },  
  11.                 {  
  12.                     "render": function (data, type, full, meta) {  
  13.                         return `class='btn btn-primary btn-sm' onclick='del(` + full.Id + `)'>class='fas fa-user-edit'>`  
  14.                     }  
  15.                 }  
  16.             ]  
  17.         });  
  18.     });  
  19.   
  20.   
  21.     function del(id) {  
  22.         window.location.href = "@Url.Action("delete", "shipment")?id=" + id;  
  23.     }    
  24.   
 
0
  • 0
    in my  shipmentitemlist this is my url. the id=2 is the parent.
     
    localhost:57546/shipment/shipmentitemlist?id=2
    0
  • Tamal Marick
    0
    Hi Denmark,
    I asked you for shipmentitemlist() method not view.
    0
  • 0
    hi  sorry for the late reply
    Tamal Marick
    1.         public ActionResult ShipmentItemList(int id)  
    2.         {  
    3.             ViewBag.ShipmentId = id;  
    4.             return View();  
    5.         }  
    6.   
    7.         public JsonResult GetShipmentItemList(int shipmentId)  
    8.         {  
    9.             var shipmentItem = (from s in _shipmentItemService.GetAll()  
    10.                                 join sh in _shipmentService.GetAll() on s.ShipmentId equals sh.Id  
    11.                                 join p in _packageService.GetAll() on s.PackageId equals p.Id  
    12.                                 where sh.Id == shipmentId  
    13.                                 select new ShipmentItemListModel  
    14.                                 {  
    15.                                     Id = s.Id,  
    16.                                     ShipmentName = sh.VesselName,  
    17.                                     PackageNumber = p.ReferenceNumber,  
    18.                                     TrackingNumber = p.TrackingNumber,  
    19.                                     ClientName = (p.Client != null ? p.Client.FirstName + " " + p.Client.MiddleName + " " + p.Client.LastName + " " + p.Client.Suffix : ""),  
    20.                                     Status = p.Status  
    21.                                 });  
    22.   
    23.             return Json(new { data = shipmentItem.ToList() }, JsonRequestBehavior.AllowGet);  
    24.         }  
    0
  • Ahmed Abdi
    0
    Hi 
     
    The problem is in this line 3
    1. var ShipmentId = _shipmentService.GetAll();   
    are you sure that you are getting the shipmentId from  _shipmentService.GetAll();
    0