Get cell's data using GridPanel's Mouseover
I have a standard GridPanel with one column containing verbose text. I want to shorten the text and display the complete text in a mouse over. If each row of the grid has a unique ID specified in a JsonReader it should be quite simple. I'm having trouble figuring this out.
PHP Code:
grid.on('mouseover', function(e,t,a) {
var row = this.getView().findRowIndex(t);
var col = this.getView().findCellIndex(t);
}
I found this snippet searching the forums but I'm not sure how I get a row's id or even a particular cell's actual data. I've read the GridPanel and GridView docs but nothing jumps out at me. I'm basically just looking to mouseover a cell of a Description column and get the ID from that same row. Not just the row id but the actual data contained in that ID cell.
It seems inefficient to mouseover the entire grid then use if statements to make sure you're over the right cell, is there a way to just mouseover a single cell? Like grid.element.on() or something like that? If so what is the proper way to reference that cell?
Also the arguments to the function passed to grid.on are a mystery to me. I assume e=event, t=target, what about a?
Thank you.
Changing the background of Header information while on Grid Mouse
var view = this;
this.gridItemMouseOver = function(gridView, el, eOpts) {
var cellIndex = el.cellIndex;
if (el.cellIndex == undefined && el.offsetParent != undefined && el.offsetParent.cellIndex != undefined)
cellIndex = el.offsetParent.cellIndex;
if (cellIndex > 0) {
var hdEl = this.getView().getHeaderAtIndex(cellIndex);
if (hdEl != undefined) {
hdEl.addCls('x-column-header-over');
setTimeout(function () {
if (hdEl != undefined)
hdEl.removeCls('x-column-header-over');
}, 99999);
}
}
};
this.gridItemMouseOut = function(gridView, el, eOpts) {
var cellIndex = el.cellIndex;
if (el.cellIndex == undefined && el.offsetParent != undefined && el.offsetParent.cellIndex != undefined)
cellIndex = el.offsetParent.cellIndex;
if (cellIndex > 0) {
var hdEl = this.getView().getHeaderAtIndex(cellIndex);
if (hdEl != undefined) {
setTimeout(function () {
if (hdEl != undefined)
hdEl.removeCls('x-column-header-over');
}, 500);
}
}
};
this.onGridRender = function () {
this.mon(this.body, {
cellclick: {fn: view.gridItemMouseOver, scope: this},
celldblclick: {fn: view.gridItemMouseOver, scope: this},
itemclick: {fn: view.gridItemMouseOver, scope: this},
itemmouseenter: {fn: view.gridItemMouseOver, scope: this},
itemmouseleave: {fn: view.gridItemMouseOut, scope: this},
mouseover: {fn: view.gridItemMouseOver, scope: this},
mouseout: {fn: view.gridItemMouseOut, scope: this},
containerclick: {fn: view.gridItemMouseOver, scope: this},
containerdblclick: {fn: view.gridItemMouseOver, scope: this},
containermouseup: {fn: view.gridItemMouseOver, scope: this},
containermouseover: {fn: view.gridItemMouseOver, scope: this},
containermouseout: {fn: view.gridItemMouseOut, scope: this},
beforeitemmouseenter: {fn: view.gridItemMouseOver, scope: this},
beforeitemmouseout: {fn: view.gridItemMouseOut, scope: this}
});
};
this.grid.on('afterrender', this.onGridRender, this.grid);
//I wish you a good day :D