3.2.0

Is there a way of setting the max lenght of a cell on edit

Is there a way of setting the max lenght of a cell on edit.

The grid will (later) update a database And I do not want to exceed the max length of the DB column.

PS I am on AW version 2.00
C Pfeiffer
July 30,
I tried the following code. It does stop the entry of data longer then 5 chars but then the grid is in a strange state the cell is highlighed but I can no longer edit the grid. or even select different cells.

Any thoughts?

var obj = new AW.UI.Grid; //NOTE I AM USING VERSION AW 2.00
obj.setCellData(function(col, row){return col + "." + row}); 
obj.setHeaderText("header"); 
obj.setColumnCount(10); 
obj.setRowCount(10); 
obj.setCellEditable(true); 
document.write(obj); 

obj.onCellTextChanging = function(text, column, row){ 
    if (text.length > 5){ 
    alert("Maxiumum length if 5 value will be truncated");
    var text2 = text.substring(0,5);
    obj.setCellText(text2 , column, row);
    obj.refresh();
       return ; 
    } 
}
C Pfeiffer
July 30,
I seem to have narrowed it down to the obj.refresh() line.

I even tried obj.getCellTemplate(column, row).refresh() instead but with the sam result
C Pfeiffer
July 30,
To cancel text change you should just return non-zero error code from the event handler -

obj.onCellTextChanging = function(text, column, row){ 
    if (text.length > 5){ 
       return 1; // cancel text change
    } 
}
Alex (ActiveWidgets)
July 31,
I've just noticed your remark regarding using AW 2.0.0 - I am not sure this code will work correctly in 2.0.0 due to some bugs relating to editing/validation (if it does not, please check with the more recent version).
Alex (ActiveWidgets)
July 31,
Is there any work around for AW 2.0.0

The only reason I ask is becuase my project is on a very tight deadline and I do not think we can afford the time and effort of doing an upgrade and retesting everything.
C Pfeiffer
August 1,
Failing any work-around option what is the upgrade path and cost.
I will need this information for the decission makers.
C Pfeiffer
August 1,
Hi Alex

Back the original proble in AW 2.0.0

I think I almost have it licked.

it seems if I do this :
obj.onCellTextChanging = function(text, col, row){ 
     if (col == 1) { 
          if (text.length > 15){ 
              alert("Maxiumum length if 15 value will be truncated");
          } 
     }
}

obj.onCellValidated = function(text, col, row){	
     if (col == 1) {
          if (text.length > 15){ 
                var text2 = text.substring(0,15);
                MyData[row][col] = text2;
                objsetCellText(text2,col,row); 
          } else {
                arr[row][col] = text;
          }
     }

     //obj.setCellText(function(c,r){return MyData[r][c]} );
     //objSelectedItems.setRowCount(arrMyData.length  );
     //objSelectedItems.setColumnCount(2 );
     //objSelectedItems.setSelectedRows([]);	
     //objSelectedItems.refresh();

     //LoadGrid();
    
}


The above code (in onCellTextChanging) alerts the user that they have entered over the char limit.

Then the onCellValidated event set the grid source (MyData JS array).
But when I try to refresh the grid (commented out code) I get the grid frozen error i originally discribed.

You will notice a function call LoadGrid() in my code. if I call it in-line here I get the same bug BUT if I call it from a button click everythin is fine.

The only difference I can see here is
1) the grid has lost focus on the button click but not with the inline code.
2) Any time delay between using the in-line code or the button.
I do not believe the time delay is the reason because I tried timeouts.

Is there any hope for version AW 2.0.0 here?
C Pfeiffer
August 1,
I guess your current problem is unrelated to AW 2.0.0 (the AW 2.0.0 bugs were about updating the input box text after canceling onCellTextChanging event). As far as I understand you are trying to refresh another grid, not the one which is edited. Try to moving your action from onCellValidated to onCellEditEnded event and maybe add some timeout.

I would still recommend to consider an upgrade, because AW 2.0.0 had been released in 2006 and does not support IE7 and also does not support Firefox2 or Firefox3. You should at least upgrade to 2.0.2 which is fully compatible with 2.0.0 and you can get it free of charge (send email to sales@activewidgets.com ).

http://www.activewidgets.com/general.bugs/2-0-2.html

Upgrade to AW 2.5.2 costs USD 295.

http://www.activewidgets.com/licenses/upgrades.htm


Alex (ActiveWidgets)
August 1,
Hmmm... Interesting

No I am editting in place

I tried your sugesstion about moving the code from onCellValidated to onCellEditEnded.

The seems to have done the trick I didn't even need to add a timeout.

I will continue to test and try to break it.
What was you thought behind adding a timeout

As for support ability.
This an internal application and we are still on IE 6.0.29... (but we maybe moving to IE7 someday)
I have no need to support firefox (yet)








C Pfeiffer
August 1,

This topic is archived.

See also:


Back to support forum