显示工具提示onHover SlickGrid的行提示、工具、SlickGrid、onHover

2023-09-05 04:36:15 作者:轻吻诀别

林新手使用jQuery。

我有个任务,把一个提示一个slickgrid的每一行上。 我知道如何阿贾克斯它。但是,阅读slickgrid文档没有什么像悬停或工具提示选项。

我的电话是这样的:

  VAR电网=新gridd.Grid(#伊特,结果,
                [{ID:VAR1,现场VAR1},
                    {ID:VAR2,现场VAR2},
                    {ID:VAR3,现场VAR3,宽度:100,可调整大小:假},
                    {ID:VAR4,现场VAR4,宽度:110,可调整大小:假}],
                {forceFitColumns:真},
                //我想到了什么样
                {onHover:功能..},
                //
                {的onClick:功能(即行,单元格){
                    VAR的结果= this.getData();

                    postSomething(结果[行]);
                }
            });
 

解决方案

一个选项,让你的信息是订阅到网格的事件 OnMouseEnter在 OnMouseLeave在。 LIB你想有文本跟随鼠标移动的,你可以使用任何工具提示。

使用的情况下,发现你是上面的哪个单元。我用一个数据视图因此需要使用 view.getItem 的情况下,任何行已经过滤掉了。如果你只是简单的显示数据,而无需过滤的,我相信数据[cell.row] 将工作,而不是,但你需要测试。

宏基笔记本如何重装系统

这只会让你的信息将在工具提示,你需要使用像这得到它在跟随鼠标的工具提示。对于我的测试,我刚刚更新的标签(与ID = boringLabel )和标签正确更新。

  VAR电网=新Slick.Grid(选择,查看,COLS,选择采用);

....

grid.onMouseLeave.subscribe(函数(即参数){
    $(#boringLabel)文本(无)。
});

grid.onMouseEnter.subscribe(函数(即参数){
    VAR细胞= args.grid.getCellFromEvent(E);
    VAR项目= view.getItem(cell.row);
    $(#boringLabel)文本(item.id ++ item.description);
});
 

Im newbie with jquery.

I've a task to put a tooltip on each row of a slickgrid. I know how to ajax it. But, reading the slickgrid documentation there's nothing in options like "hover" or "tooltip".

my call is like that:

var grid = new gridd.Grid("#ite", result,
                [{ id: "var1", field: "var1" },
                    { id: "var2", field: "var2" },
                    { id: "var3", field: "var3", width: 100, resizable: false },
                    { id: "var4",  field: "var4", width: 110, resizable: false}],
                { forceFitColumns: true },
                //I thought of something like
                { onHover: function.. },
                //
                { onClick: function (e, row, cell) {
                    var result = this.getData();

                    postSomething(result[row]);
                }
            });

解决方案

One option that gets you the information is to subscribe to the grid's events onMouseEnter and onMouseLeave. The you can use whatever tooltip lib you want to have the text follow the mouse.

Use the event to discover which cell you are above. I use a dataview so need to use view.getItem in case any rows have been filtered out. If you are simply showing data without filtering, I believe data[cell.row] will work instead, but you'll need to test.

This will only get you the information to put in the tooltip, you'd need to use something like this to get it in a tooltip following the mouse. For my test, I just updated a label (with id=boringLabel) and the label updated correctly.

var grid = new Slick.Grid(selector, view, cols, opts);

....

grid.onMouseLeave.subscribe(function(e, args) {
    $("#boringLabel").text("NONE");
});

grid.onMouseEnter.subscribe(function(e, args) {
    var cell = args.grid.getCellFromEvent(e);
    var item = view.getItem(cell.row);
    $("#boringLabel").text(item.id + " " + item.description);
});