Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
95
How to set Focus on Grid Cell?
posted

I have a grid which is two banded, InvestmentCategory has one or more InvestmentGroups. I enter InvestmentGroups under one InvestmentCategory. I want to detect the Duplicate investmentGroup under one investmentCategory and if duplicate is detected, I want to setfocus on that cell. I have written JavaScript in AfterCellUpdateHandler, clientside event handler. But this is not working. Duplicate detection works fine but setFocus does not work.  SelectionType of Column is defined as single.

Here is how the code looks like,

function investmentCategoryUltraWebGrid_AfterCellUpdateHandler(gridName, cellId){

//Add code to handle your event here.

 

var col=igtbl_getColumnById(cellId);

if(col.Key!='description')

return;var cell=igtbl_getCellById(cellId);

 

var Data=cell.getValue();

 

var row=cell.Row;

var index=row.getIndex();

//Finding Parent Row.

var parentRow=row.ParentRow;

 

//Now Finding Child RowCount of this Parent

 

var childRowCount=parentRow.ChildRowsCount;

 

for(var i=0;i<=childRowCount;i++)

{

if(index!=i) //Skip the one selected

{

var processingRow= parentRow.getChildRow(i);

var processingCellObj=processingRow.getCell(1);

var processingCellValue=processingCellObj.getValue();if(processingCellValue==Data)

{

alert(
'Duplicate detected, Please check your data');

cell.setSelected(); //THIS PART OF THE CODE DOES NOT WORK,

cell.activate();

break;

}

}

}

}

Thank you very much for your help. 

 

Parents
No Data
Reply
  • 19308
    posted

    It would be helpful to know what exactly isn't working.  Is the cell not being selected, or is focus not transferring?  Or is there a Javascript error being thrown?  My first guess is that the alert is interfering with what you're trying to do.  The problem with an alert box is that it's modal, and transfers focus away from what you're doing.  So even though you're trying to set focus to the cell, the Alert window is stealing the focus.  Try doing the same thing with out the alert, and see if that works better for you.  If so, I'd recommend using the Infragistics WebDialogWindow, since it is much more controllable than the standard alert box.  You can use the DialogWindow's closed event to then 'activate' the appropriate cell in the grid.

    Hope this helps,

    -Tony

Children