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

Do Not allow Add New Record if condition is fale

1 Answer 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian K
Top achievements
Rank 1
Brian K asked on 25 Aug 2020, 05:17 PM
I have a radgrid that its datasource takes three inputs before executing.  I also want to allow for inserts to take place, but those three dropdown selections must be made prior to allowing a user to insert a record.  How can I prevent the edit form for showing if the selections are not made prior to clicking the Add New Record buttion on the radgrid?

1 Answer, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 28 Aug 2020, 02:56 PM

Hi Brian,

A command is fired each time a user interacts with the Grid. Be it paging, sorting, filtering or even editing. So when the user clicks on the Edit or Insert button, you capture the command event, and during that you can verify if all 3 options are selected as needed. If not, you can then cancel the command. In this case there will be a PostBack but nothing will change as the command was canceled.

You can check out the ItemCommand Event for more information.

Also, I recommend reviewing the Command ReferenceTelerik RadGrid lifecycle, and Event sequence articles. These will help you get a better understanding on the topic.

Regards,
Attila Antal
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Grid
Asked by
Brian K
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Share this question
or