Telerik Forums
UI for Silverlight Forum
2 answers
60 views

Hi,

Can't seem to find the way to set CommandButtonsVisibility from code behind. I'm building a user control with dynamic behavior the DataForm.

In XAML it's easy and working.

Anybody that has an idea?

Thanks in advance!

Kurt

Kurt Landuyt
Top achievements
Rank 1
 answered on 27 Feb 2018
3 answers
126 views
Hi,

I've run into a problem with the RadDataForm where I cannot seem to get the Cancel button to become enabled.

The problem exists in a much more complicated app, but I created a small test app to see if I could get it to work in a very simple implementation, however it still does not.

    <UserControl.Resources>
        <local:ViewModel x:Key="vm"/>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White" DataContext="{StaticResource vm}">
        <telerik:RadDataForm ItemsSource="{Binding Data}"/>
    </Grid>

Data is an Observable collection defined in the ViewModel. Data is of Type 'DataClass' . Both the ViewModel and DataClass implement INotifyPropertyChanged.

I've looked at the demo (http://demos.telerik.com/silverlight/#DataForm/FirstLook) where it appears to work, and there doesn't seem to be anything different there from what I have above.
Stefan
Telerik team
 answered on 09 Jan 2017
17 answers
802 views
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.
Stefan Nenchev
Telerik team
 answered on 21 Dec 2016
3 answers
91 views

I have a RadDataForm with several DataFormDataFields and also some combo boxes.

I need to attach some event handlers to the fields that are triggered whenever the user starts to edit the text contents in a field. I am using a data template to define the fields included in the form. I would like to have, in my data template, something like this, for example:

                    <telerik:DataFormDataField Label="Client's Name"
                                               Grid.Row="16"
                                               Width="500" HorizontalAlignment="Left" TextChanged="DataFormDataField_TextChanged"
                                               DataMemberBinding="{Binding PaymentRequest.ClientName, Mode=TwoWay}" />

 

and then in the code behind:

        private void DataFormDataField_TextChanged(object sender, System.Windows.Input.TextCompositionEventArgs e)
        {

            etc....
        }

 

Unfortunately, the DataFormDataField does not provide a TextChanged event. I have tried instead using the TextInput (or TextInputStart event). This fires fine when the user types additional text into the field, but the event does not get fired when, for example, the user presses the backspace delete key. I need an event that will fire whenever the pre-filled text starts to get changed. Any ideas?

 

Martin
Telerik team
 answered on 15 Nov 2016
8 answers
93 views

Hi,

 It would be extremely useful to have an virtual method that is called during the form's Validation process, that could be overridden ​to provide custom validation results to be injected into the ValidationSummary in place of the form's own validation. I've taken a look at some of the code and something like the following would be great. This is a small change to the existing code which I don't think would have any impact on other existing functionality:

    /// <summary>
    /// Checks if data current item is valid .
    /// 
    /// </summary>
    /// 
    /// <returns/>
    public bool ValidateItem()
    {
      CollectionExtensions.RemoveItems<ErrorInfo>((ICollection<ErrorInfo>) this.validationErrors, (IEnumerable<ErrorInfo>) new List<ErrorInfo>(Enumerable.Where<ErrorInfo>((IEnumerable<ErrorInfo>) this.validationErrors, (Func<ErrorInfo, bool>) (ve => ve.IsItemLevelValidationError))));
      List<ValidationResult> validationResults = new List<ValidationResult>();
      if (this.CurrentItem != null)
      {
        try
        {
          validationResults.AddRange(GetValidationResults())
        }
        catch
        {
          return true;
        }
      }
      CancelEventArgs e = new CancelEventArgs();
      this.OnValidatingItem(e);
      if (e.Cancel)
        return false;
      this.PopulateValidationErrors(validationResults);
      return !EnumerableExtensions.IsNotEmpty((IEnumerable) this.validationErrors);
    }

      protected virtual IEnumerable<ValidationResult> GetValidationResults()
      {
          Validator.TryValidateObject(this.CurrentItem, new ValidationContext(this.CurrentItem, (IServiceProvider) null, (IDictionary<object, object>) null), (ICollection<ValidationResult>) validationResults, true);
      }

John
Top achievements
Rank 1
 answered on 03 Nov 2016
3 answers
105 views
Hello,
I working with RadDataForm and Custom template.

I was using this and it was working.
<telerik:DataFormComboBoxField Grid.Row="2" MinHeight="28"
      ItemsSource="{Binding VehicleCategories, Source={StaticResource locationVM}}"
      DataMemberBinding="{Binding VehicleCategory}" DisplayMemberPath="Label"
      SelectedValuePath="Code">
</telerik:DataFormComboBoxField>
But I need to use a RadComboBox For doing some specific stuff so I change my code like this.

<telerik:DataFormComboBoxField Grid.Row="2" MinHeight="28">
 <telerik:DataFormComboBoxField.ContentTemplate>
  <DataTemplate>
   <telerik:RadComboBox
     ItemsSource="{Binding VehicleCategories, Source={StaticResource locationVM}}"
     SelectedItem="{Binding VehicleCategory}" DisplayMemberPath="Label"
     SelectedValuePath="Code"/>
  </DataTemplate>
 </telerik:DataFormComboBoxField.ContentTemplate>
</telerik:DataFormComboBoxField>

But that introduce a problem and the binding on my attribute VehicleCategory is not working anymore.


Any problem with my code? 

I prefer correcting this before introducing a special template for the RadComboBox.

Thank you,
Nasko
Telerik team
 answered on 12 Oct 2015
4 answers
102 views
Hello,

I have a RadDataForm that is bound to a collection of records.  This form, when a record is edited should trigger an action in the view model that calls a web service to update the record in a downstream system.  My ultimate challenge is that I do not know how to refer back to the ViewModel (or if it is even possible) from the Custom Command provider.  Any help would be greatly appreciated!


Code Snippet from my XAML:

        <telerik:RadDataForm Header="Balance Inquiry"
                             x:Name="IcsManualOpDataForm"
                             AutoGeneratingField="IcsManualOpForm_AutoGeneratingField"
                             ItemsSource="{Binding BalanceInq}"
                             AutoGenerateFields="True">
            <telerik:RadDataForm.CommandProvider>
                <commandProvider:IcsManualOpCommandProvider DataForm="{Binding ElementName=IcsManualOpDataForm}"/>
            </telerik:RadDataForm.CommandProvider>
        </telerik:RadDataForm>


The Custome Command provider (called IcsManualOpCommandProvider) is defined as follows:
    public class IcsManualOpCommandProvider : DataFormCommandProvider
    {
        public IcsManualOpCommandProvider()
            : base(null)
        {
            
        }

        protected override void CommitEdit()
        {
            // TODO: call web service
           this.DataForm.CommitEdit();

        }
    }
Stefan
Telerik team
 answered on 03 Jul 2015
6 answers
234 views
I have a mulitline textbox in my raddataform's edit template, with AcceptsReturn="True".
When the user hits enter in this feild, instead of getting a new line, the dataform submits and ends the edit. 

This thread seems to indicate this shouldn't be an issue:
 http://www.telerik.com/community/forums/silverlight/data-form/multiline-dataformdatafield.aspx 

How can I get this to work correctly?
I am using the lastest release 2013 Q2.
Thanks.

<DataTemplate x:Key="Note_EditTemplate">

<StackPanel>

<telerik:DataFormDataField DataMemberBinding="{Binding Note, Mode=TwoWay}" Label="Note :" >

<TextBox Text="{Binding Note, Mode=TwoWay}" TextWrapping="Wrap" Height="100" Width="300" AcceptsReturn="True" MaxLength="1024"/>

</telerik:DataFormDataField>

<telerik:DataFormDataField DataMemberBinding="{Binding Created, StringFormat=d}" Label="Created :" IsReadOnly="True" />

<telerik:DataFormDataField DataMemberBinding="{Binding Modified, StringFormat=d}" Label="Modified :" IsReadOnly="True" />

</StackPanel>

</DataTemplate>

 

<telerik:RadDataForm Grid.Column="1" x:Name="data_UnitNotes" ItemsSource="{Binding UnitNotes.View}" VerticalAlignment="Top"

CommandButtonsVisibility="Add,Edit,Delete,Cancel,Commit" AutoGenerateFields="False" Margin="5,0,0,0"

AddedNewItem="data_UnitNotes_AddedNewItem_1" DeletedItem="data_UnitNotes_DeletedItem_1"

BeginningEdit="data_UnitNotes_BeginningEdit_1" EditEnded="data_UnitNotes_EditEnded_1"

EditTemplate="{StaticResource Note_EditTemplate}"

ReadOnlyTemplate="{StaticResource Note_ReadTemplate}"

 NewItemTemplate="{StaticResource Note_EditTemplate}"/>

 

 

 

Rami Abughazaleh
Top achievements
Rank 1
 answered on 01 Apr 2015
8 answers
248 views
Hello,

Just installed the last version (Q1, 2011) of Telerik Silverlight controls, and tried Telerik DataForm control by replacing the standard DataForm control in one of my the projects.

I observed two wrong behaviors so far:

1. I found no way, at least not obvious way, of stretching vertically the content within the DataForm. In my application I host the DataForm into a resizable RadPanel, inside the DataForm I have a multiline text field which is anchored on all edges, so it is supposed to resize when the DataForm resizes to benefit by the whole surface of the DataForm (this worked with standad DataForm control).
I set on RadDataForm the VerticalAlign and VerticalContentAlight to Stretch
I set also the VerticalAlign="Stretch" for the control inside the DataForm

Please let me know if there is a way to achive desired behavior.

2 A second observation I have is that if I do not specify a Foreground color for the RadDataForm the labels inside various templates would be displayed with White foreground over White background.  I don't use any special theme... just plain controls with their default style.

This can be reproduced with very simple code in brand new project

Vasile
Murali
Top achievements
Rank 1
 answered on 15 Feb 2015
9 answers
150 views
Hi, 
I have a problem with a DataFormComboBoxField generated in code behind as suggested by your example

Here is the code for generate the field
e.DataField = GetComboField(columnFieldProp, e.DataField.DataMemberBinding);
e.DataField.Loaded += delegate(object o, RoutedEventArgs eventArgs)
{
      var field = o as DataFormComboBoxField;
      foreach (RadComboBox child in field.ChildrenOfType<RadComboBox>())
       {
            var comboBox = child;
            if (comboBox != null)
           comboBox.SetBinding(RadComboBox.SelectedValueProperty, e.DataField.DataMemberBinding);
       }
};



private DataFormComboBoxField GetComboField(ToolColumnFieldProp columnFieldProp, Binding dataBinding)
        {
            DataFormComboBoxField combo = new DataFormComboBoxField();
            combo.SelectedValuePath = columnFieldProp.ComboBoxSelectedPath;
            combo.DisplayMemberPath = columnFieldProp.ComboBoxDisplayPath;           
            object context = Code.Utility.CreateInstance(columnFieldProp.ComboBoxAssemblyName, columnFieldProp.ComboBoxContextNameSpace);
            combo.ItemsSource = Code.Utility.GetComboBoxItemSource(context);          
            combo.DataMemberBinding = dataBinding;          
            return combo;
        }

XAML
<telerik:RadDataForm x:Name="rdDataForm"  Header="{Binding Title}" CurrentItem="{Binding Current, Mode=TwoWay}" telerik:StyleManager.Theme="Office_Blue"
                    ItemsSource="{Binding List, Mode=TwoWay}" AutoGeneratingField="rdDataForm_AutoGeneratingField"   Grid.Row="0" AutoCommit="False"
                      EditEnded="rdDataForm_EditEnded" DeletedItem="rdDataForm_DeletedItem"  CommandButtonsVisibility="Cancel,Commit" LabelPosition="Beside"
                     >
     
</telerik:RadDataForm>

The ComboBoxField is correctly generated, and correctly bound to selected value. 
The problem is that when i go in edit mode, the combobox loses the selected value.

I have the same identical problem in the GridView that is bound to same collection.

Could you please help me?

Best regards
kannan
Top achievements
Rank 1
 answered on 07 Oct 2014
Top users last month
horváth
Top achievements
Rank 2
Iron
Iron
Steve
Top achievements
Rank 2
Iron
Erkki
Top achievements
Rank 1
Iron
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
Jakub
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?