Aug 17, 2015, 12:05 AM
[CLOSED] MVC Grid Cell Tooltip
This question is an extension of this link: http://forums.ext.net/showthread.php...ooltip-Problem
I still can not seem to get the tooltip to appear when added through the controller for a cell. Here is the code I worked up that demonstrates the problem.
=================C# Controller=======================
===============Model===========================
==============View==========================
Thanks in advance.
I still can not seem to get the tooltip to appear when added through the controller for a cell. Here is the code I worked up that demonstrates the problem.
=================C# Controller=======================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Ext.Net;
using Ext.Net.MVC;
using TPWC.Models;
namespace TPWC.Controllers
{
public class BigQuestionController : Controller
{
// GET: BigQuestion
public ActionResult Index()
{
return View();
}
public ActionResult CreateQuestionGrid()
{
GridPanel grid = new GridPanel();
grid.Title = "ToolTipTest";
Store store = new Store();
Model model = new Model { IDProperty = "ID" };
GridView gView = new GridView { StripeRows = true };
grid.View.Add(gView);
AjaxProxy ajaxProxy = new AjaxProxy { Url = Url.Action("GetStore", "BigQuestion") };
ajaxProxy.Reader.Add(new JsonReader { Root = "data" });
store.Proxy.Add(ajaxProxy);
grid.Store.Add(store);
Button refreshButton = new Button { Text = "Reload", Icon = Icon.ArrowRefresh };
refreshButton.Listeners.Click.Handler = "this.up('grid').getStore().reload();";
Toolbar topTool = new Toolbar();
grid.TopBar.Add(topTool);
topTool.Items.Add(refreshButton);
ToolTip tTip = new ToolTip();
tTip.Target = grid.ClientID;
//tTip.Target = "#{" + grid.ClientID + "}";
tTip.Delegate = ".x-grid.cell";
tTip.IsDynamic = true;
tTip.TrackMouse = true;
tTip.AutoHide = false;
tTip.Hidden = false;
//tTip.Html = "testing";
tTip.Listeners.Show.Handler = "onShow(this, #{" + grid.ID + "});";
//tTip.Listeners.Show.Handler = "onShow(this, " + grid.ID + ");";
grid.ToolTips.Add(tTip);
Column idCol = new Column { DataIndex = "ID", Text = "ID Header", Flex = 1 };
grid.ColumnModel.Columns.Add(idCol);
model.Fields.Add(new ModelField { Name = "ID", Type = ModelFieldType.Int });
Column col1 = new Column { DataIndex = "Column1", Text = "Header", Flex = 1 };
grid.ColumnModel.Columns.Add(col1);
model.Fields.Add(new ModelField { Name = "Column1", Type = ModelFieldType.String });
store.Model.Add(model);
return this.ComponentConfig(grid);
}
public ActionResult GetStore()
{
List<BigQuestion> questionList = BigQuestion.QuestionTestData;
return this.Store(questionList);
}
}
}
=============================================================Model===========================
using System;
using System.Collections.Generic;
using System.Web.Mvc;
using Ext.Net;
using Ext.Net.MVC;
namespace TPWC.Models
{
public class BigQuestion
{
public int ID { get; set; }
public string Column1 { get; set; }
public static List<BigQuestion> QuestionTestData
{
get
{
return new List<BigQuestion>
{
new BigQuestion{ID = 1, Column1="fred@flintstone.com"},
new BigQuestion{ID = 2, Column1="wilma@flintstone.com"},
new BigQuestion{ID = 3, Column1="pebbles@flintstone.com"},
new BigQuestion{ID = 4, Column1="barney@rubble.com"},
new BigQuestion{ID = 5, Column1="betty@rubble.com"},
new BigQuestion{ID = 6, Column1="bambam@rubble.com"}
};
}
}
}
}
=========================================================View==========================
@{
var X = Html.X();
ViewBag.Title = "Question Page";
Layout = "~/Views/Shared/_BaseLayout.cshtml";
<script>
var onShow = function (toolTip, grid) {
var view = grid.getView(),
store = grid.getStore(),
record = view.getRecord(view.findItemByChild(toolTip.triggerElement)),
column = view.getHeaderByCell(toolTip.triggerElement),
data = record.get(column.dataIndex);
toolTip.update(data);
};
</script>
}
@(X.ResourceManager(ViewBag.ManagerConfig as MvcResourceManagerConfig))
@section mainStuff
{
@(X.Panel()
.Title("Question Panel")
.Items(
X.Panel()
.Layout(LayoutType.Fit)
.Resizable(true)
.Loader(X.ComponentLoader()
.Url(Url.Action("CreateQuestionGrid", "BigQuestion"))
.Mode(LoadMode.Component)
.LoadMask(lm => lm.ShowMask = true)
)
)//Panel Items
)
}
I have commented out some of the things I have tried.Thanks in advance.
Last edited by Daniil; Aug 17, 2015 at 6:23 PM.
Reason: [CLOSED]