RadDataForm Enable/Disable Add/Edit/Delete?

16 posts, 0 answers
  1. Brian
    Brian avatar
    58 posts
    Member since:
    Jul 2011

    Posted 04 Oct 2011 Link to this post

    Is there a way to set a RadDataForm to read-only and either hide or disable the add/edit/delete buttons?  I need to enable or disable the ability of the user to edit data on the form at runtime.
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 04 Oct 2011 Link to this post

    Hi Brian,

    Try setting RadDataForm's CommandButtonsVisibility property to "Navigation". In this way you will hide all the commands buttons, except for these from the navigation panel.

    All the best,
    Ivan Ivanov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. DevCraft banner
  4. Brian
    Brian avatar
    58 posts
    Member since:
    Jul 2011

    Posted 04 Oct 2011 Link to this post

    Ivan,
    Thanks, that works for me.
  5. s2uiguy
    s2uiguy avatar
    24 posts
    Member since:
    Jan 2011

    Posted 17 Nov 2011 Link to this post

    Is there a way to set just Edit, Commit, and Cancel???
    Thanks!
  6. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 18 Nov 2011 Link to this post

    Hello Bobby,

    Generally, the visibility of 'Add'/ 'Delete' buttons depends on the data source collection and whether it supports inserting/ removing items. If your collection allows you to add/delete items, but you still want to remove the buttons, you can edit the template of RadDataForm and remove those buttons that you do not want to be displayed.
     

    Kind regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  7. Jeff
    Jeff avatar
    100 posts
    Member since:
    Apr 2008

    Posted 25 Jan 2012 Link to this post

    I find this kind of answer to be enormously frustrating.

    I am currently banging my head against the wall, trying to get add/delete buttons to show up in a WPF RadDataForm, and browsing the web brought me to this answer.

    "Generally, the visibility of 'Add'/ 'Delete' buttons depends on the data source collection and whether it supports inserting/ removing items."

    Great.  Which data source collections support inserting/removing items?  What specifically is RadDataForm looking for, when it decides whether the bound collection supports inserting/removing items?  Is it looking for whether the collection implements specific interfaces?  Implements specific methods?  Handles specific events?

    And where is this documented? Where do I go, in the documentation, to determine what I need in my collection to trigger specific behaviors in the control?
  8. Dempsey
    Dempsey avatar
    8 posts
    Member since:
    Jul 2012

    Posted 30 Nov 2012 Link to this post

    Gee, I completely agree with this comment.
    >> I find this kind of answer to be enormously frustrating.
    I've spent nearly 2 hours now on your site trying to figure out how to get my Delete icon to activate in my RadDataForm. I finally thought I had found the answer, but then I too find that I am given only a hint and no answer. This is indeed enormously frustrating! And it's not just this answer but many answers found on here. Is it possible, Maya, to provide the missing information?


  9. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 03 Dec 2012 Link to this post

    Hello Dempsey,

    I am really sorry to see that you have troubles working with RadDataForm and its documentation. We will do our best to improve it and add article concerning inserting, deleting, canceling editing, etc.
    Actually, RadDataForm works as an items control - if the collection itself supports insert/ delete functionality (has Add/Remove methods for example), it will invoke them and add or remove an item. That is why we did not introduce article explaining such scenarios.
    However, in order to avoid any frustration from now on, we will try to improve the documentation. Let me know in case you have other problems with it so that we can make it better.

    Kind regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  10. Dempsey
    Dempsey avatar
    8 posts
    Member since:
    Jul 2012

    Posted 11 Dec 2012 Link to this post

    Hi, Maya.
    Thank you for your reply. After all this time, I'm still unable to get the Delete icon (the trashcan) to be enabled on my RadDataForm. You guys told us that:

    >> Generally, the visibility of 'Add'/ 'Delete' buttons depends on the data source collection
    >> and whether it supports inserting/ removing items.

    What's a bit frustrating is that information seems fairly hard to figure out. I myself am using an ICollection View, and in other parts of my program (a child window), I can select an item and then punch a button that caused that item to be added to the ICollection. So it appears to me that my data source collection does indeed "supports inserting/removing items." Still, though, the Delete icon never becomes enabled.

    In  my dataform, I have the following Command Buttons Visibility settings:

    >>   CommandButtonsVisibility="Cancel, Commit, Edit, Delete, Navigation"

    Since the Delete icon never becomes enabled, I'm sure I'm doing something wrong, and *perhaps* it is that my collection type doesn't truly meet the criteria you mentioned. I think what Jeff was referring to, and what I agreed with, is that your previous answer seems to provide only a "clue" to an answer but not a thorough answer. In particular, for this situation, how do I know if ICollection truly "supports inserting/removing items?" Furthermore, what *other* collections would/would-not quality for turning on the Delete capability for a RadDataForm? Having that information would make for a great, complete, non-frustrating answer.

    Just a suggestion...
    Dempsey
  11. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 12 Dec 2012 Link to this post

    Hi,

    The article for Add, Edit and Delete functionality of RadDataForm in already available in our documentation.
    Considering the frustration that you have, the behavior of the data form is just as any other items control. So, if you are able to add/ remove items from a DataGrid for example, you will be able to do that in the form as well.
    Nevertheless, I would recommend you to run through this article and its subsequent ones for more information on different types of collections and the functionality they provide.    

    Greetings,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  12. Tim
    Tim avatar
    3 posts
    Member since:
    Jul 2012

    Posted 16 Jul 2013 Link to this post

    I'm having a similar issue with RadDataForm (RadControls for Silverlight Q2 2013). The add Add New Item button is disabled. However, the ItemSource is an ObservableCollection, which supports the Add method. Also, this code was working at some point before upgrading to Q2 2013. However, I might have done something else to make this break, any suggestions?

    Thanks
    Tim

    AdminViewModel.cs:

    public ObservableCollection<EditableContact> Contacts
            {
                get { return contacts ?? (contacts = new ObservableCollection<EditableContact>()); }
                set { Set("Contacts"ref contactsvalue); }
            }

    View.xaml:
    DataContext="{Binding AdminViewModel, Source={StaticResource Locator}}">
    

    <DataTemplate x:Key="ContactsTemplate">
                <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5,15,5,5" Background="WhiteSmoke">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <telerik:DataFormDataField Grid.Row="0" Label="Company:"
                                               DataMemberBinding="{Binding Company, Mode=TwoWay}" />
                    <telerik:DataFormDataField Grid.Row="1" Label="Name:" DataMemberBinding="{Binding Name, Mode=TwoWay}" />
                    <telerik:DataFormComboBoxField Grid.Row="2" Label="Type:"
                                                   ItemsSource="{Binding DataContext.ContactTypes, ElementName=LayoutRoot}"
                                                   DataMemberBinding="{Binding Type, Mode=TwoWay}" />
                    <telerik:DataFormDataField Grid.Row="3" Label="Email:" DataMemberBinding="{Binding Email, Mode=TwoWay}" />
                    <telerik:DataFormDataField Grid.Row="4" Label="Phone1:"
                                               DataMemberBinding="{Binding Phone1, Mode=TwoWay}" />
                    <telerik:DataFormDataField Grid.Row="5" Label="Phone2:"
                                               DataMemberBinding="{Binding Phone2, Mode=TwoWay}" />
                    <telerik:DataFormDataField Grid.Row="6" Label="Extension:"
                                               DataMemberBinding="{Binding Extension, Mode=TwoWay}" />
     
                    <telerik:DataFormDataField Grid.Row="7" Label="Notes:" DataMemberBinding="{Binding Notes, Mode=TwoWay}" />
                    
                </Grid>
            </DataTemplate>

    <telerik:RadDataForm x:Name="EditContactsForm" AutoGenerateFields="False" Margin="3,3,3,3"  
                                         Header="Edit Contacts" ItemsSource="{Binding Contacts }"
                                         ReadOnlyTemplate="{StaticResource ContactsTemplate}"
                                         EditTemplate="{StaticResource ContactsTemplate}"
                                         NewItemTemplate="{StaticResource ContactsTemplate}"
                                         >
                    </telerik:RadDataForm>

    Model: 
    public class EditableContact : ContactIEditableObject
    

  13. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 17 Jul 2013 Link to this post

    Hi Tim,

    Will it be possible to verify whether you have a default parameterless constructor for your business object ?  

    Regards,
    Maya
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  14. Tom
    Tom avatar
    1 posts
    Member since:
    Mar 2015

    Posted 22 Jul 2015 in reply to Maya Link to this post

    This has to be the worst response to what should be a simple answer, why don't you provide an example of how to get the DELETE button to show up?  You keep responding like a robot, we wan't straight answers without having to be told by the SUPPORT team that we pay to go read an article when the answer is probably something rather simple.  Why don't you provide an example.
  15. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 23 Jul 2015 Link to this post

    Hi Brian,

    We provide multiple example where Delete button is enabled and you can refer to our Demos as well as our SDK browser. Once DataForm is bound to a source collection that supports Remove functionality, the Delete button will be enabled. 
    Do you have some specific scenario with custom collection or anything else that does not support removing the items ? 


    Regards,
    Maya
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  16. Jeff
    Jeff avatar
    100 posts
    Member since:
    Apr 2008

    Posted 23 Jul 2015 in reply to Maya Link to this post

    It's been a few years since I posted my complaints in this thread. I am not, in fact, using Telerik controls any longer, except while maintaining what are now legacy apps.  (No complaint against Telerik, in particular, it's just we're no longer writing asp.net websites).

     

    My complaint is simply that the documentation is incomplete.

    Take this "explanation", as an example:

     

    "if the collection itself supports insert/ delete functionality (has Add/Remove methods for example), it will invoke them and add or remove an item."

     

    That is a meaningless remark. The collection isn't capable of determining whether the collection supports insert/delete functionality. All it can do is use reflection to examine the properties and methods that are available on the collection. It might see a method Insert(), and assume that the collection supports inserts. Or it might not see a method Insert(), and though there is a method insert(), that doesn't match what it's looking for so it assumes that it doesn't support inserts.

     The logic within the control by which it determines whether a collection supports insert or delete isn't documented. What methods need to be present in the collection for the control to decide whether it can do inserts? Whether it can do deletes? These should be explicitly documented, and the last time I went through the documentation, they weren't.

     

     

  17. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 27 Jul 2015 Link to this post

    Hello Jeff,

    Thanks for the feedback, we will take care for updating the documentation so that it contains more information about the ability to insert/ delete items. 
    And in order to shed some more light in this thread, I will provide a bit more explanations. 

    Insert operation is enabled or disabled based on the CanAddItems property of RadDataForm. It is set like:
    private void SetCanAddItems()
        {
            this.CanAddItems = this.ItemsSource != null && this.FormViewModel.Items.CanAddNew && !this.IsAddingNew &&  his.CanExecuteWhenAutoCommitFalse();
        }

    So, it needs ItemsSource and to verify that you are not adding items at the moment. CanAddNew of the Items collection depends on the CanAddNew property of the EditableCollectionView of the source. The last method returns:
    private bool CanExecuteWhenAutoCommitFalse()
    {
        return this.AutoCommit ? true : !this.HasChangesToCommit;
    }

    AutoCommit is the corresponding property of the data form, HasChangesToCommit evaluates the modifications made.

    Considering delete command, it depends on CanDeleteItems property of the data form:
    private void SetCanDeleteItems()
            {
                this.CanDeleteItems = this.ItemsSource != null && this.FormViewModel.Items.Count != 0 && this.FormViewModel.Items.CanRemove && !this.IsAddingNew;
            }

    I guess its elements speak for themselves.

    In case there is some misunderstanding or something is not clear enough, I will be happy to provide the missing information. 



    Regards,
    Maya
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft banner