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,
//Add code to handle your event here.
if(col.Key!='description')
var row=cell.Row;
//Finding Parent Row.
//Now Finding Child RowCount of this Parent
{
if(index!=i) //Skip the one selected
var processingCellObj=processingRow.getCell(1);
cell.setSelected(); //THIS PART OF THE CODE DOES NOT WORK,
cell.activate();
}
Thank you very much for your help.
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
I tried to remove alert but still no luck. Actually the problem is, focus not transferring to the cell where duplicate is detected.
Lets say, I have Data
01 - Row-1
02- Row-2
03- Row-3
02- Row-4
Newly added Row
When i tab at Row-4 it creates new Row and Since 02 is duplicate because we already have it a Row-2, now I want the focus to be at 02 in Row-4 and selected.
Hello,
Please use the following code, I had the same issue But the following code works for me,
Example to check the entered cell value is a whole number
var curCell = igtbl_getCellById(itemName);var curCellValue = curCell.Element.innerText;
curCell.setValue(prevCellValue, false); // Hold the previous value from the before enter edit mode handler
Regrads,Chaitanya...
You should execute your code on the BeforeEndEdit event rather than the UpdateCell event, and rather than setting the selected/active cell you should cancel the event - preventing the user from actually leaving the cell.
http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/WebGrid_Client_Side_Events_CSOM.html
You'll want to return true from the method to cancel the event. Here's some pseudo-code
function Grid_BeforeExitEditMode(gridName, cellID){ var cell=igtbl_getCellByID(cellID); if( cellValueIsDuplicate) return true;}