dhtmlxGrid Edit and check/uncheck problem

Hi,
I am newbie in using dhtmlxGrid and I am using the dhtmlxGrid for the first time in my application. I have a dhtmlxGrid with 4 colums and I am using the following code to define my column types and attach events:

[code]gGrid.setHeader("#,Cost,Quanity,Total Item Cost");
gGrid.setColTypes(“ch,ro,ed,price”);
gGrid.enableEditEvents(false,true,false);
gGrid.attachEvent(“onEditCell”, doOnEditCell);

function doOnEditCell(Stage,RowID,CellIndex,NewValue,OldValue)
{
if (Stage == 2)
{
if(CellIndex == ‘2’)
{
var NewItemCost = parseFloat(NewValue).toFixed(2) * parseFloat(gGrid.cells(RowID, 1).getValue()).toFixed(2);

				NewItemCost = NewItemCost.toFixed(2)			
				gGrid.cells(RowID,7).setCValue(NewItemCost);			
				return IsValidQuantity;						
			}	  
			else
			{
				alert('A Valid Quantity Should Be Defined.');
				return IsValidQuantity;	
			}    		  			
      		}	
	}

[/code]

I have the following problems:

  1. The dhtmlxGrid doesn’t let me check/uncheck my “#” column.
  2. When I enter a value in “Quanity” and press TAB key then “my “Total Item Cost” displays 0 in that column. (It works only with ENTER key)
  3. The dhtmlxGrid is also letting me edit my “Total Item Cost” column as well which I want to stop.
    Thanks

Please, have a look at the comments in your function

function doOnEditCell(Stage,RowID,CellIndex,NewValue,OldValue)
{
if (CellIndex==‘3’){return false}// this line can help you to block the editing of the last column
if (Stage == 2)
{
if(CellIndex == ‘2’)
{
var NewItemCost = parseFloat(NewValue).toFixed(2) * parseFloat(gGrid.cells(RowID, 1).getValue()).toFixed(2);

           NewItemCost = NewItemCost.toFixed(2)         
           gGrid.cells(RowID,7).setCValue(NewItemCost);         // colInd=7 in your grid there are only 4 columns (max_value ==3)
           return IsValidQuantity;                  
        }     
        else 
        {
           alert('A Valid Quantity Should Be Defined.');
           return IsValidQuantity;   
        }                     
            }   

return true // this line will allow you to edit the column with check box
}

Hi,

Thank you very much. This is what I am looking for.

Thanks