View Full Version : gridView.findRowIndex - extjs 4 equivalent?

27 Sep 2011, 2:56 AM
I am migrating an Ext JS 3 app. We had a tooltip on a grid panel that would get its content in this fashion

beforeshow: function updateTipBody(tip) {
var rowIndex = view.findRowIndex(tip.triggerElement);
var record = store.getAt(rowIndex);
tip.body.dom.innerHTML = getSomeHtml(record);

Where view and store are in an outer scope.

But I cannot see any equivalent way in ext js 4 to get hold of a record given an element in the grid's row.

And I haven't yet come across any documentation on a recommended way to do tooltips for grid items.


27 Sep 2011, 3:26 AM
Simple grid tooltips are usually done using a quicktip. You'd use a tdAttr in the renderer to specify a data-qtip.

To answer your other question, I don't think there's a direct equivalent but you should be able to get to the record reasonably simply. Maybe findItemByChild() (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.View-method-findItemByChild) to get the item node then getRecord() (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.View-method-getRecord).

27 Sep 2011, 6:17 AM
I tried using data-qclass as well as data-qtip on the renderer. It seems qclass is not picked up internally?


metaData.tdAttr = 'data-qclass="sometip" data-qtip="' + record.data[record.idProperty] + '"';

in initComponent:

Ext.tip.QuickTipManager.getQuickTip().on('beforeshow', function (quicktip) {
if (quicktip.activeTarget.cls == 'sometip') {
quicktip.activeTarget.text = getSomeHtml(me.getStore().getById(quicktip.activeTarget.text));

The class/cls property is not set on the activeTarget of the quicktip. That stopped me from setting anything dynamically on the quicktip. But since I knew I wanted dynamic content anyway, qtips are probably not the answer

beforeshow: function updateTipBody(tip) {
var rowEl = Ext.get(tip.triggerElement).findParentNode('.x-grid-row');
var record = view.getRecord(rowEl);

is what i needed.