How to call a partial view inside jquery datatable?
How to call a partial view inside jquery datatable?
This is the main view
<table id="myGrid1" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Order ID</th>
<th>Customer ID</th>
<th>ContactName</th>
<th>Employee ID</th>
<th>Order Date</th>
<th>Required Date</th>
<th>Ship Via</th>
<th>Freight</th>
<th>Ship name</th>
<th>Ship Address</th>
<th>Ship City</th>
<th>Ship Region</th>
<th>Ship Postal</th>
<th>Ship Country</th>
</tr>
</thead>
<tbody></tbody>
<tfoot>
<tr>
<th>Order ID</th>
<th>Customer ID</th>
<th>ContactName</th>
<th>Employee ID</th>
<th>Order Date</th>
<th>Required Date</th>
<th>Ship Via</th>
<th>Freight</th>
<th>Ship name</th>
<th>Ship Address</th>
<th>Ship City</th>
<th>Ship Region</th>
<th>Ship Postal</th>
<th>Ship Country</th>
</tr>
</tfoot>
</table>
$(document).ready(function () {
$('#myGrid1').DataTable({
"ajax": {
"url": "/Test/GetData",
"type": "GET",
"dataSrc": "",
"method": "GET",
"dataType": "json",
" destroy": true
},
"columns":
[
{ "data": "OrderID" },
{ "data": "CustomerID" },
{ "data": "ContactName" },
{ "data": "EmployeeID", },
{ "data": "OrderDate" },
{ "data": "RequiredDate" },
{ "data": "ShipVia" },
{ "data": "Freight" },
{ "data": "ShipName" },
{ "data": "ShipAddress" },
{ "data": "ShipCity" },
{ "data": "ShipRegion" },
{ "data": "ShipPostalCode" },
{ "data": "ShipCountry" }
]
});
});
And this is the parial view
@model IEnumerable<Northwind.Order_Detail>
Product ID | Product | Unit Price | Quantity | Discount |
---|---|---|---|---|
@item.ProductID | @item.Product.ProductName | @item.UnitPrice | @item.Quantity | @item.Discount |
And this is the controller ::
public class TestController : Controller
{
private dbNorthwindEntities db = new dbNorthwindEntities();
Orders or = new Orders();
// GET: Test
public ActionResult Index()
{
return View();
}
public ActionResult Index1()
{
return View();
}
public ActionResult Me(int? OrderID)
{
var detalet = db.Order_Details;
var orderDetalet = (from e in detalet
where (OrderID == null || e.OrderID == OrderID)
select e).ToList();
return View(orderDetalet);
}
public JsonResult GetData()
{
try
{
using (db = new dbNorthwindEntities())
{
var myList = or.GetOrders(db);
return Json(myList, JsonRequestBehavior.AllowGet);
}
}
catch (Exception)
{
throw;
}
}
What I want is when i click a row in datatable , to open up partial view as modal (like alert function in javascript) , with details for every Order , so how to open a partial view inside a row click in datatable ?!