Dynamically change EditType of Grid Column

Hello,

Using  the inline edit mode of the grid, I'd like to change the EditType of a Column based on the selection from a DropDownList on the page.  The options in the list are String, Integer and Number (Decimal). 

I've tried setting the EditType property to a variable which is updated when the DropDownList selection is changed, but when anything but String is selected, the column editor is blank when the row is edit mode.

I've also tried to modify the EditorSettings in a similar fashion with no success.

The desired outcome is that when "String" is selected, any value may be added in the column.  When Integer is selected, only numbers, no decimals are allowed.  When Number is selected a number with up to 3 decimals is allowed.

Any help is greatly appreciated!


3 Replies

RN Rahul Narayanasamy Syncfusion Team March 30, 2022 02:56 AM UTC

Hi Lee,


Greetings from Syncfusion.


We understood your query and we suspect that you want to change the EditType of the column dynamically. We need some details regarding your requirement. Could you please share the below details which will be helpful to validate and provide a better solution?


  • Whether the mentioned dropdown(changing dropdown) is rendered outside of the Grid?
  • Whether did you want to change the EditType of the column before entering into the edit mode?
  • (Or) did you want to change the EditType while the record is in EditMode?
  • Complete Grid code snippets of the page and video demonstration.
  • Share a simple reproducible sample which depicts your scenario.
  • Share your requirement in more detail.


Regards,

Rahul



LE Lee replied to Rahul Narayanasamy March 31, 2022 05:47 PM UTC

The issue is that the underlying datatype of the field that the column is bound to is "string".  When you try to change it to EditType.Numeric, no input is rendered due to the conflicting datatype.

I've worked around this by using an edit template and adding additional properties to bound class that are of the double datatype and then in the setter of those properties, they update the primary property that I use to save to my DB.  And of course, I have logic in the template that determines what input should be rendered and what property it's bound to.

There are probably other ways to handle this, but it's working for now.

Thanks!

Lee Phillips



MS Monisha Saravanan Syncfusion Team April 1, 2022 01:14 PM UTC

Hi Lee,


Thanks for the update


We are glad to hear that you have resolved your query on your own. Kindly get back to us if you need further assistance.


Regards,

Monisha


Loader.
Up arrow icon