How to set the data of a field with EditType of NoEdit using JavaScript?

6 replies. Last post: September 22, 2010 10:48 PM by Handy Surya
Tags :
  • (None)
Shawn AugustMember

I have a field with EditType of NoEdit to prevent the user from editing this field.  However, I still need to set this field using JavaScript.  This is possible using the Cell's SetChanges() Method but not the Cell's SetText() method.  However, I noticed some weirdness with the SetChanges() Method where it would clear the field but leave the underlying textbox's tooltip showing previous data. This only seemed to occur when setting the text to "".


For example,

Cell.SetChanges("Hello World") = "Hello World" and tooltip of "Hello World"

Cell.SetChanges("") = "" and tooltip of "Hello World"

Cell.SetText("Hello World") = "" and tooltip of "" for field's with EditType=NoEdit

 

The Cell'sSetForceNoEdit() method generates an exception "this.CellElement" is null or not an object

Answers

Hello Shawn,

Do you mean for each cell? Because we don't have EditType for row. We only have EditType for WebGrid Column in cell level.
You should not be able to do at row level. Besides, Row object does not have SetText() method.

In order to do this in No Edit type, you can use SetText(). Please see the code below.

function Button1_onclick() {
            var grid = ISGetObject("WebGrid1");
            grid.GetSelectedObject().ToRowObject().GetCells()[1].SetText("Hello World", true,true);
           
        }

The last parameter is ignore edit type parameter. You can return true or false.

Regards,
Handy

All Replies

Hello Shawn,

Do you mean for each cell? Because we don't have EditType for row. We only have EditType for WebGrid Column in cell level.
You should not be able to do at row level. Besides, Row object does not have SetText() method.

In order to do this in No Edit type, you can use SetText(). Please see the code below.

function Button1_onclick() {
            var grid = ISGetObject("WebGrid1");
            grid.GetSelectedObject().ToRowObject().GetCells()[1].SetText("Hello World", true,true);
           
        }

The last parameter is ignore edit type parameter. You can return true or false.

Regards,
Handy

Hello Shawn,

Do you mean for each cell? Because we don't have EditType for row. We only have EditType for WebGrid Column in cell level.
You should not be able to do at row level. Besides, Row object does not have SetText() method.

In order to do this in No Edit type, you can use SetText(). Please see the code below.

function Button1_onclick() {
            var grid = ISGetObject("WebGrid1");
            grid.GetSelectedObject().ToRowObject().GetCells()[1].SetText("Hello World", true,true);
           
        }

The last parameter is ignore edit type parameter. You can return true or false.

Regards,
Handy

 

 

My apologies as I meant Cell when I typed Row. The last parameter sounds exactly like I need! It is not listed in the documentation anywhere so I was not aware it existed. Is there any other parameters?

 

I will test in the morning.

Fantastic! This allowed me to update the field regardless if the EditType was set to NoEdit.


However, the textbox's tooltip still has the previous data.

 

For example,

Cell.SetText("Hello World", true, true) = "Hello World" and tooltip of "Hello World"

Cell.SetText("", true, true) = "" and tooltip of "Hello World"

 

Can you confirm?

Hello Shawn,

I did not face the issue in tooltip at all. Would you mind to send me a simple sample of yours? 
FYI, I also tested with your snippet code.

Regards,
Handy

Hello Shawn,

I did not face the issue in tooltip at all. Would you mind to send me a simple sample of yours? 
FYI, I also tested with your snippet code.

Regards,
Handy

 

Oddly. I can't seem to reproduce in another project. I can't get the tooltip to consistantly be displayed to even see what the tooltip is.

Hello Shawn,

The tooltip only shows when the word length extends a cell width. Should you also see the same in your scenario?

Regards,
Handy

All times are GMT -5. The time now is 12:03 AM.
Previous Next