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

Conditinally hide all Child Tables 'Add New Records' Command Item Template Button based on Master Table Column Value

1 Answer 45 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
gc_0620 asked on 22 Aug 2019, 12:46 AM

Using Telerik .Net Ajax with VS 2015 and 2017.

Below Telerik Link is my prototype.

In my MasterTableView I have a column named 'IsClosed' which is Bit data type in SQL and is a GridBoundColumn in RadGrid.

My question is if column 'isClosed' is true in MasterTableView

1) I would like just to disable 'Add New Records' Commanditem Template Button invisibile to all related GridTableView's but keep 'Refresh'
CommandItem Template Button's available.

2) MasterTableView ''Add New Records' Commanditem Template Button should be visible/enabled.

Thanks a lot


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 26 Aug 2019, 12:37 PM

Both of these requirements are possible:

2. The command item can be enabled from here and you probably have this set already in your app:
<MasterTableView ... CommandItemDisplay="Top">

1. Now, for the first requirement, there are two options:

If the condition is depending on a database value - you can use the ItemDataBound event handler and access the isClosed value of the individual records:

Then, if it is true, you can access the command item using the GetItems method:

Finally, all you need to do is to use the commandItemInstance.FindControl("ID") method to access the buttons and toggle their visibility or enabled state:
- for refresh button: the ID is RefreshButton
- for insert button: the ID is AddNewRecordButton

If the condition is depending on the checkbox selection made by the user when the item is in edit mode, you can access the CheckBox control using ItemCreated event handler and enable its AutoPostBack property:

Then, you can hook on its change event and in the code behind you can use (sender as CheckBox).Checked to get the condition value. The rest of the process is analogous to the previous step.

I hope this will prove helpful.

Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question