Yea, I know...that's a lot to ask. I've gotten very close. My code is below.
What I need is a tooltip that renders the results of a partial view when user hovers a specific column (column #6) in the kendo grid (mvc razor). I need to show a list of active orders for the given row in the grid.
If the row.OnOrder = 0, I see the proper tooltip text "- no orders found -".
But when row.OnOrder > 0 and the AJAX call is necessary, the tooltip just shows an empty tooltip box (shown in screenshot). In Chrome Network tab I can see the ajax call made, and I can see the html response of the partial view. So I'm fairly certain the partial call is working and responding correctly. VS debugger shows the controller gets hit and returns the view. But the result doesn't populate to the tooltip. I just get a little grey box.
I feel like I'm missing some really, really small but I can't tell what. Any suggestions? The partial view does have a kendo grid in it as well, if that matters.
document.ready():
$("#grdStockLevels").kendoTooltip({
filter: "td:nth-child(6)", // Adjust the selector to target the specific column
position: "top",
content: function (e) {
var dataItem = $("#grdStockLevels").data("kendoGrid").dataItem(e.target.closest("tr"));
if (dataItem.OnOrder > 0) {
return $.ajax({
url: '@Url.Action("OpenOrderList", "Purchasing")',
type: 'GET',
async: false,
data: {
productId: dataItem.ProductId,
optionList: dataItem.OptionList
},
dataType: 'html'
});
} else {
return "- no open orders -";
}
}
}).data("kendoTooltip");
Controller partial view:
public ActionResult OpenOrderList(int productId, string optionList)
{
// validate product
Product p = _productRepo.Load(productId);
if (p == null) return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
// locate open order items
var orderItemList = p.SupplierOrderItems.Where(z => z.OptionList == optionList && z.Order.OrderStatus.IsActive).ToList();
IList<SupplierOrderModel> model = orderItemList.Select(x => new SupplierOrderModel()
{
OrderNumber = x.Order.OrderNumber,
EtaDate = x.Order.EtaDate,
SupplierShipMethodId = x.QtyRemain
}).ToList();
return PartialView("_OpenOrderListPopup", model);
}
partial view:
@model IList<SupplierOrderModel>
@(Html.Kendo().Grid(Model)
.Name("grdOpenOrderList")
.Columns(columns =>
{
columns.Bound(p => p.OrderNumber).Title("Order Number");
columns.Bound(p => p.EtaDate).Title("ETA Date").Format("{0:MM/dd/yyyy}");
columns.Bound(p => p.PurchaseMethodId).Title("Qty On Order");
})
.HtmlAttributes(new { style = "height: 550px;" })
)