This is a migrated thread and some comments may be shown as answers.

Update Readonly column in edit mode

3 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rayne
Top achievements
Rank 1
Rayne asked on 04 Mar 2014, 08:37 PM
There is a column (B) in my grid that is read only and it's value is dependent on the value of another column (A).

What I'd like is for the value of B to be updated when the row is in edit mode (or insert) and the value of A is changed. So for example when the input box for value A changes or loses focus. Because if the value of B isn't retrievable, then the value of A is invalid I'd like to notify the user of this before they save the invalid record.
Makes sense? Can anyone help?

I can see an easy way to do this for insert by extracting the insert from the grid, but I'd like to keep it in the grid if possible to match edit mode.

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 07 Mar 2014, 02:05 PM
Hello,

If I understand your scenario correctly the column A would have only number of valid entries based on the value in column B. If this is the case you could use a column that renders a control with limited options to choose from like GridDropDownColumn for instance. This way the user would not be able to enter values that are not valid.

Moreover if the entered value is validated on the server this would generate additional requests and could lead to performance penalty.

If I have misunderstood your scenario would you elaborate more on the setup that you have? What is the EditMode used for the RadGrid? What binding is used for the control? Also what is the relation between the two columns?

Regards,
Viktor Tachev
Telerik

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

0
Rayne
Top achievements
Rank 1
answered on 17 Mar 2014, 02:03 PM
Sort of. The list of possible values for column A is too long for a drop down (over 1000 possible values). It is a number and the value of column B is a descriptive text of that value, but its pulled from a different database. 

So column A has a key value. column B is the name of that key value. Then there are other columns that are editable to set up administrative requirements. These values, plus A are editable in one database. the value in column B is read-only from another database (the lookup db). So value A gets validated from the lookup db (it must exists in that db). the name is fetched from lookup db, but value A plus the other admin columns are stored in a different database.

When the grid is bound to an object data source which pulls the data from the two separate databases. This is an administrative page, and inserts/updates won't be frequent once the data is set up, so performance shouldn't be an issue validating during edit.

Right now if the value is invalid, column B is just blank once the grid saves and refreshes, but I'd rather prevent the save and force the user to correct the value.

Does this help clarify?

0
Viktor Tachev
Telerik team
answered on 20 Mar 2014, 01:54 PM
Hello Rayne,

Thank you for the clarification.

In this situation you could use a CustomValidator control for column A. The validator control could check if the entered value is valid and if not- prevent the update.

Another approach you could use is handle the OnUpdateCommand for RadGrid. You would need to check the values entered by the user and if they are not valid - cancel the update and prompt the user to enter valid data.

If you need further assistance do not hesitate to contact us again.

Regards,
Viktor Tachev
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
Grid
Asked by
Rayne
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Rayne
Top achievements
Rank 1
Share this question
or