
Before export to Excel we add aggregate function:
var sumFunction = new CountFunction()
{
ResultFormatString = " ({0} items): "
};
column.AggregateFunctions.Add(sumFunction);
Export functionality:
var options = new GridViewExportOptions
{
Format = ExportFormat.ExcelML,
ShowColumnHeaders = true,
ShowColumnFooters = true,
ShowGroupFooters = true,
Encoding = Encoding.UTF8
};
var fileToExportTo = exportFileInfo.FullName;
using (FileStream fs = new FileStream(fileToExportTo, FileMode.OpenOrCreate))
{
gridControl.Export(fs, options);
}
Exception: Object reference not set to an instance of an object.
at Telerik.Windows.Controls.GridViewBoundColumnBase.<>c__DisplayClass18.<Telerik.Windows.Controls.IExportableColumn.GetCellContent>b__12(AggregateFunction f) in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Columns\GridViewBoundColumnBase.cs:line 55
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Telerik.Windows.Controls.GridViewBoundColumnBase.Telerik.Windows.Controls.IExportableColumn.GetCellContent(Object parameter) in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Columns\GridViewBoundColumnBase.cs:line 56
at Telerik.Windows.Controls.GridViewExportWriter.RenderHeaderOrFooterCells(ExportElement element, Object context) in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Exporting\GridViewExportWriter.cs:line 692
at Telerik.Windows.Controls.GridViewExportWriter.RenderFooterRow() in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Exporting\GridViewExportWriter.cs:line 535
at Telerik.Windows.Controls.GridViewExportWriter.Render() in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Exporting\GridViewExportWriter.cs:line 101
at Telerik.Windows.Controls.GridView.GridViewDataControl.Export(Stream stream, GridViewExportOptions options) in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Exporting\GridViewDataControl.Exporting.cs:line 31
I have an annotation on my timeline which I want to move up/down in time.
I know I can just change the annotations Date to do this, but How can I get the user to interact with the annotation.
It does not trigger the SelectionChanged event (cos it's not a item).
Is there a way to identify it the mouse down, move and up events, so I can calculate it's new Date value there??

Hi Team,
I am using Telerik grid. I am able edit data in the telerik grid cells.If i want to save the edited data, I am facing an issue.
Example: First cell i entered data and press Save button it is not taking edited cell value.If i move to the second cell then only first cell data was saveing.
Can you please check and help me here.
Please find attcahed attcahed xaml file.
Thanks,
Siva
Hi,
I am using RadScheduleView to display multiple calendars, I have defined group filter function in my view model and it is binded to the view definition in XAML, When I select resources and add a new calendar first time the group filter function gets called 9 times, I have just 4 resources + date group, Second time it gets called like 100 times and the application hangs. Is this a issue in group filter or am i doing something wrong.
Thanks
vikas
_departmentResourceType.Resources.Add(new Resource("Department - 1", "Department"));
_departmentResourceType.Resources.Add(new Resource("Department - 2", "Department"));
_locationResourceType.Resources.Add(new Resource("Location - 1", "Location"));
_locationResourceType.Resources.Add(new Resource("Location - 2", "Location"));
_allResourceTypes.Add(_departmentResourceType);
_allResourceTypes.Add(_locationResourceType);
Hello,
I have a question about traversing the focus when a selection is made in the RadComboBox.
I have the following requirement:
When the user enters the combobox, the drop down should automatically open (I set OpenDropDownOnFocus= true) , the user will select an item and confirm the selection by using the enter key. After that the item should be set, the drop down should be closed and the focus should automatically traverse to the next field. Travesersing focus to the next field should be done by the enter-key, I already implemented this for textboxes.
I have used below code with the regular WPF ComboBox, but this gave some unexpected behavior in the past.
Sometimes the warning was shown ("Couldn't move the focus.......) and the user was not able anymore to traverse the focus in the whole screen using the enter key, he needed to close the screen and open it again to re-enable this functionality.
public class CustomComboBox : ComboBox{ #region Fields private bool _focused = false; #endregion #region Methods protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) { base.OnGotKeyboardFocus(e); _focused = true; } protected override void OnDropDownClosed(EventArgs e) { if (_focused) { var uie = this as UIElement; _focused = false; } else { base.OnDropDownClosed(e); } } protected override void OnKeyDown(KeyEventArgs e) { if ((e.Key == System.Windows.Input.Key.Enter)) { base.OnKeyDown(e); var comboBoxItem = e.OriginalSource as FrameworkElement; var comboBox = ItemsControl.ItemsControlFromItemContainer(comboBoxItem) as ComboBox; if (comboBox != null) comboBox.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next)); else { LogManager.GetLog(this.GetType()).Warn("Couldn't move the focus to the next field, source: {0}.", e.OriginalSource); } } else base.OnKeyDown(e); } #endregion}
What is the best way to accomplish this, or is this functionality already in the RadComboBox?
Regards,
Marcel
I'm in need to display a RadListBox with some Items as ItemsSource. Those items are of type DataFieldOption and the have properties ID (int) and Name (string).
Here are some examples:
DataFieldOption 1: ID = 184, Name = "German"
DataFieldOption 2: ID = 185, Name = "English"
DataFieldOption 3: ID = 186, Name = "French"
...
The SelectionMode of my ListBox is Multiple. I already read the Telerik blog about how to handle the SelectedItems property so I created the necessary helper class and named it ListBoxSelectedItemsHelper.
public class ListBoxSelectedItemsHelper { #region Fields public static readonly DependencyProperty SelectedItemsProperty; #endregion #region Constructors static ListBoxSelectedItemsHelper() { SelectedItemsProperty = DependencyProperty.RegisterAttached("SelectedItems", typeof(IList), typeof(ListBoxSelectedItemsHelper), new FrameworkPropertyMetadata(null, OnSelectedItemsChanged)); } #endregion #region Methods #region DependencyProperty Methods #region CallBack private static void OnSelectedItemsChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var listBox = sender as RadListBox; if (listBox != null) { IList selectedItems = GetSelectedItems(listBox); if (selectedItems != null) { listBox.SelectedItems.Clear(); foreach (var item in selectedItems) { listBox.SelectedItems.Add(item); } } } } #endregion #region Getter/Setter public static IList GetSelectedItems(DependencyObject d) { return (IList) d.GetValue(SelectedItemsProperty); } public static void SetSelectedItems(DependencyObject d, IList value) { d.SetValue(SelectedItemsProperty, value); } #endregion #endregion #endregion
I must use this ListBox inside RadDataForm and I need to get the ListBox' selected items as one single string value with the help of a converter. So if three ListBox entries are selected SelectedItems will become an ObservableCollection with three objects in it. This is achieved by using the helper class from above. Now it's getting tricky. I want to use a converter that converts that ObservableCollection to a string value. Looking at the example values at the begining of my post this means: If German and French are selected in the ListBox, SelectedItems becomes ObservableCollection with two objects and this should get converted to "184;186" (the objects IDs separated by ';').
Here is my converter (it already works):
public class DataFieldOptionConverter : DependencyObject, IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values.Length == 2) { var dataFieldOptions = values[0] as IList<IDataFieldOptionDataItemViewModel>; var stringValue = values[1] as string; // if (dataFieldOptions != null && String.IsNullOrEmpty(stringValue) == false) { var parts = stringValue.Split(';'); if (parts.Any()) { var result = new List<IDataFieldOptionDataItemViewModel>(); foreach (var part in parts) { var dfo = dataFieldOptions.SingleOrDefault(x => (System.Convert.ToString(x.ID) == part)); if (dfo != null) { result.Add(dfo); } } return result; } } } // Konvertierung fehlgeschlagen return DependencyProperty.UnsetValue; }
It is a MultiValueConverter to pass in a list of all selectable items (see type DataFieldOption above) and a string value of format "184;186" to check which items are selected. This is my XAML code:
<t:DataFormDataField Label="{Binding DataField.Label, Mode=OneWay}" Description="{Binding DataField.ToolTip, Mode=OneWay}" DataMemberBinding="{Binding Value, Mode=OneWay}"> <tx:CustomRadListBox ItemsSource="{Binding DataField.DataFieldOptions, Mode=OneWay}" DisplayMemberPath="Name" SelectedValuePath="ID" SelectionMode="Multiple"> <tx:ListBoxSelectedItemsHelper.SelectedItems> <MultiBinding Converter="{StaticResource DataFieldOptionConverter}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"> <Binding Path="DataField.DataFieldOptions" /> <Binding Path="Value" /> </MultiBinding> </tx:ListBoxSelectedItemsHelper.SelectedItems> </tx:CustomRadListBox></t:DataFormDataField>
I tried to get this to work for days now and I'm really running out of ideas. What I need is a RadListBox with SelectionMode = multiple and I want to save the users selection as a single string value in a database. Later that value is read from the database (for example "184;186;188") and it has to be converted back to a list of selected items so the ListBox gets back to its saved state. And all this inside RadDataForm. Can you provide any help on this?
I am building a custom control that inherits RadDatePicker and overrides the OnParseDateTime method to implement custom parsing logic. One of the requirements of this logic is being able to parse a date in the MM/dd/yy format. Unfortunately, whenever a date is entered in that format, the control changes the CurrentDateTimeText, but not the DateTimeText, and thus the ParseDateTimeValue event is never raised.
What's curious is that I have a similar control (derived from RadDateTimePicker) that accepts that format and raises the ParseDateTimeValue event as expected, even without a time value. However, if its InputMode is changed to "DatePicker", then it will no longer parse dates with a two-digit year.
Is this a known bug, or am I missing something?
Hi I am using RadGridView 4.0 for one of my application.
It was building successfully but at run-time I am getting exception - 'Set connection Id ...' , when I get into detail it is saying
Could not load file or assembly 'Telerik.Windows.Data, Version=2013.3.1016.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' or one of its dependencies. The system cannot find the file specified.
I am using the libraries from nuget package for WPF 4.0 [ RadControls.for.Wpf.40.2013.3.1016] - All same versions
Telerik.Windows.Controls
Telerik.Windows.Controls.GridView
Telerik.Windows.Controls.Input
Telerik.Windows.Controls.Navigation
Telerik.Windows.Data
Please respond ASAP as we have start UAT for our application, and it is giving errors on forms with telerik radgridview.
We are a licensed User of Telerik with customer Id ZS1376728
Quick Resolution Required or we have to switch to standard datagrid
Thanks & Regards,
Vikas Sharma