PDA

View Full Version : To shift focus from one normal gridpanel to property grid



omniuser
12 Aug 2010, 2:31 PM
Hi,

I have 2 grids namely a normal grid panel more like a help list which describes various properties. If i click on a specific property it should actually shift the focus from this grid to a property grid and select/ highlight that property. I am able to scroll to the property in the property grid but not able to highlight it..:((



function helpList_clickHanlder(grid, rowIndex,columnIndex,e)
{
var record = grid.getStore().getAt(rowIndex);
var field = grid.getColumnModel().getDataIndex(columnIndex);
if (field == 'editIcon')
{
var property = record.get('fieldName');
var type = record.get('fieldType');
if (type == 'Header')
{

Portal.User.focusProperty(localRef.headerDefaultsList,property);
localRef.headerDefaultsList.focus();
return;
}
else if (type == 'Line')
{
Portal.User.focusProperty(localRef.lineDefaultsList,property);
}
}
}
Portal.User.focusProperty = function(grid, propertyName)
{
for ( var i=0; i<grid.store.getCount();i++)
{
var record = grid.getStore().getAt(i);
var prop = record.get('name');
//console.debug(propertyName);

if (propertyName == prop)
{
grid.getView().focusEl.focus(true);
//grid.focus(propertyName);
grid.getSelectionModel().select(i);
grid.getView().focusRow(i);
var row = grid.getView().getRow(i)
grid.getView().getRowStyle = function(record, rowIndex, rp, ds){ rp.bodyStyle = 'test';return 'test';}
//grid.startEditing(i,1);

}
}
}


Any help on this would be highly appreciated. Thanks!!

Animal
12 Aug 2010, 9:37 PM
selecting a Record will highlight a row!

And there are built in ways of finding a record in a Store. You do not have to write a loop (which continues looping even after it finds the target!)

omniuser
13 Aug 2010, 6:42 AM
Animal..Thanks a lot for your pointers..I removed the loop and used jsonstore's built-in functions and voila! it works..Just posting the code for others reference


Portal.User.focusProperty = function(grid, propertyName)
{
var j = grid.getStore().findExact('name',propertyName);
grid.getSelectionModel().select(j,0,false,false,j);
}