Telerik Forums
UI for WPF Forum
6 answers
151 views

So I have a working save/load for my RadPivotGrid with LocalDataProvider, but had performance concerns so added set of wrappers and functionality for QueryableDataProvider.

My wrappers and set with properties (get; set;) of types int, double, string, bool?, string, MyEnum, DateTime[DisplayFormat(DataFormatString = "{0:dd-MM-yyyy}", ApplyFormatInEditMode = true)]

Im not applying any custom aggregates or similar, and in this example I had 1 column, 1 row property and 'count' of ItemID value.

 

The code works fine with LocalDataProvider (though not using wrappers there, instead more complex EF entities), but wit h my lighter QueryableDataProvider datasource it now my export throws an exception when it hits the serialize command `provider.Serialize(this.xPivotGrid_Reports.DataProvider)`

---

An exception of type 'System.Runtime.Serialization.SerializationException' occurred in System.Runtime.Serialization.dll but was not handled in user code

Additional information: Type 'Telerik.Pivot.Queryable.QueryablePropertyAggregateDescription' with data contract name 'QueryablePropertyAggregateDescription:http://schemas.datacontract.org/2004/07/Telerik.Pivot.Queryable' is not expected. Consider using a DataContractResolver if you are using DataContractSerializer or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to the serializer.

---

 

I cant remember original source, but I found the DataContract code online and changed very little.

And I am aware that the DataProviderSerializer subclass (where KnownTypes is defined) is called LocalDataSourceSerializer, but thats part of question: 

Is there another list like `PivotSerializationHelper.KnownTypes` I should be using, because it seems comprehensive enough and im hardly doing anything strange?

 

---

    [DataContract]
    public class DataProviderSettings
    {
        [DataMember]
        public object[] Aggregates { get; set; }

        [DataMember]
        public object[] Filters { get; set; }

        [DataMember]
        public object[] Rows { get; set; }

        [DataMember]
        public object[] Columns { get; set; }

        [DataMember]
        public int AggregatesLevel { get; set; }

        [DataMember]
        public PivotAxis AggregatesPosition { get; set; }
    }

    public class LocalDataSourceSerializer : DataProviderSerializer
    {
        public override IEnumerable<Type> KnownTypes
        {
            get
            {
                return PivotSerializationHelper.KnownTypes;
            }
        }
    }

    public abstract class DataProviderSerializer
    {
        public abstract IEnumerable<Type> KnownTypes { get; }

        public string Serialize(object context)
        {
            string serialized = string.Empty;

            IDataProvider dataProvider = context as IDataProvider;
            if (dataProvider != null)
            {
                MemoryStream stream = new MemoryStream();

                DataProviderSettings settings = new DataProviderSettings()
                {
                    Aggregates = dataProvider.Settings.AggregateDescriptions.OfType<object>().ToArray(),
                    Filters = dataProvider.Settings.FilterDescriptions.OfType<object>().ToArray(),
                    Rows = dataProvider.Settings.RowGroupDescriptions.OfType<object>().ToArray(),
                    Columns = dataProvider.Settings.ColumnGroupDescriptions.OfType<object>().ToArray(),
                    AggregatesLevel = dataProvider.Settings.AggregatesLevel,
                    AggregatesPosition = dataProvider.Settings.AggregatesPosition
                };

                DataContractSerializer serializer = new DataContractSerializer(typeof(DataProviderSettings), KnownTypes);
                serializer.WriteObject(stream, settings);

                stream.Position = 0;
                var streamReader = new StreamReader(stream);
                serialized += streamReader.ReadToEnd();
            }

            return serialized;
        }

        public void Deserialize(object context, string savedValue)
        {
            IDataProvider dataProvider = context as IDataProvider;
            if (dataProvider != null)
            {
                var stream = new MemoryStream();
                var tw = new StreamWriter(stream);
                tw.Write(savedValue);
                tw.Flush();
                stream.Position = 0;

                DataContractSerializer serializer = new DataContractSerializer(typeof(DataProviderSettings), KnownTypes);
                var result = serializer.ReadObject(stream);

                dataProvider.Settings.AggregateDescriptions.Clear();
                foreach (var aggregateDescription in (result as DataProviderSettings).Aggregates)
                {
                    dataProvider.Settings.AggregateDescriptions.Add(aggregateDescription);
                }

                dataProvider.Settings.FilterDescriptions.Clear();
                foreach (var filterDescription in (result as DataProviderSettings).Filters)
                {
                    dataProvider.Settings.FilterDescriptions.Add(filterDescription);
                }

                dataProvider.Settings.RowGroupDescriptions.Clear();
                foreach (var rowDescription in (result as DataProviderSettings).Rows)
                {
                    dataProvider.Settings.RowGroupDescriptions.Add(rowDescription);
                }

                dataProvider.Settings.ColumnGroupDescriptions.Clear();
                foreach (var columnDescription in (result as DataProviderSettings).Columns)
                {
                    dataProvider.Settings.ColumnGroupDescriptions.Add(columnDescription);
                }

                dataProvider.Settings.AggregatesPosition = (result as DataProviderSettings).AggregatesPosition;
                dataProvider.Settings.AggregatesLevel = (result as DataProviderSettings).AggregatesLevel;
            }
        }
    }

---

 

 

 

Daniel B.
Top achievements
Rank 1
 answered on 16 May 2016
0 answers
96 views

I add raddatafilter as following :

<Grid><Grid.Resources><DataTemplate x:Key="CountryComboboxTemplate" ><telerik:RadComboBox x:Name="CountryCombox2" TabIndex="3"HorizontalAlignment="Left" VerticalAlignment="Center"DisplayMemberPath="CountryName" IsTabStop="True"ClearSelectionButtonContent="Clear" ClearSelectionButtonVisibility="Visible"CanAutocompleteSelectItems="True" CanKeyboardNavigationSelectItems="True"IsEditable="True" IsReadOnly="False" IsTextSearchEnabled="True"OpenDropDownOnFocus="True" IsFilteringEnabled="True"TextSearchMode="Contains" IsDropDownOpen="False" SelectedValue="{Binding Value, Mode=TwoWay, FallbackValue=null}"Width="200" Background="{x:Null}" BorderBrush="{x:Null}" Height="30" Foreground="{DynamicResource white-forground}" Margin="0,5" Grid.Row="2" Grid.Column="2"/></DataTemplate><behaviors:EditorTemplateSelector x:Key="MyEditorTemplateSelector"><behaviors:EditorTemplateSelector.EditorTemplateRules><behaviors:EditorTemplateRule PropertyName="Country" DataTemplate="{StaticResource CountryComboboxTemplate}" /></behaviors:EditorTemplateSelector.EditorTemplateRules></behaviors:EditorTemplateSelector></Grid.Resources><telerik:RadDataFilter Name="Filter" telerik:StyleManager.Theme="Windows8"EditorCreated="OnRadDataFilterEditorCreated"Loaded="Filter_Loaded"MinHeight="193"MaxHeight="250"Width="Auto"Grid.Row="0" behaviors:FilterDescriptorBindingBehavior.FilterDescriptors="{Binding FilterDescriptors, Source={StaticResource model}}"EditorTemplateSelector="{StaticResource MyEditorTemplateSelector}"Margin="1" /></Grid>

the problem is the country not fill in the filter always country is equal too empty , not the selected country
and code behind looks like

public FilterDataUserControl(){InitializeComponent();var list = new List<FilterCriterea>();list.Add(new FilterCriterea());Filter.Source = list;}private void OnRadDataFilterEditorCreated(object sender, EditorCreatedEventArgs e){if (DataContext != null){var datacontextVm = DataContext as AdvancedSearchManagerViewModel;if (datacontextVm != null){switch (e.ItemPropertyDefinition.PropertyName){case "Country":RadComboBox countrycomboBoxEditor = (RadComboBox)e.Editor; countrycomboBoxEditor.ItemsSource = datacontextVm.CountryCollectionViewModelIns;break;}}}}private void Filter_Loaded(object sender, RoutedEventArgs e){Filter.ItemPropertyDefinitions.Add(new ItemPropertyDefinition("Country", typeof(Country), "Country"));}}

 

Ali
Top achievements
Rank 1
 asked on 13 May 2016
0 answers
89 views

Hi, I implemented an Autocompletebox within an Edit Appointment's dialog,I was able to set the ItemsSource to be a staticresource of the viewmodel, But I can't seem to set it as a property of my CustomAppointment. May I ask how do I do that.

 

Also upon creation of a new appointment, I send it off to make the changes in outlook as well. But the problem is that the code below is of type IAppointment. How do I get the value of the customappointment OnSchedulerAppointmentCreated 

        private void OnSchedulerAppointmentCreated(object sender, AppointmentCreatedEventArgs e)
        {
            (this.DataContext as CalendarViewModel).NewAppointment((CustomAppointment)e.CreatedAppointment);
        }

Minh
Top achievements
Rank 1
 asked on 13 May 2016
1 answer
78 views
I have added several columns into gridview in the code, the binding is something like a[" + Index + "].b while Index  is a number like 0,1,2. So how to solve the problem since the added column cannot be drag or sort. I have already tried set DataType, seems like not ok.
Stefan
Telerik team
 answered on 13 May 2016
1 answer
95 views

Hey all,

So to start, let me say that I have a project built out to learn with...I'm trying things out just to figure out better patterns and whatnot when building up apps since I've been doing a lot of that lately and I've started a blog to document my experiences.

What I was doing initially was creating a project to figure out which was better to use...a BackgroundWorker or Task for doing background processing of getting a data source for the grid.  What I ended up with was a test app that is buried under a mountain of bad perf and it locks the UI up until it's darn good and ready to let it go.  As far as I can tell in my source code...I'm not attaching any of the BackgroundWorker or Task threads to the UI thread...so I'm pretty confused as to what's going on.

If I just do one at a time, the table starts filling up with data before the RadBusyIndicator can even bring up it's UI...if I try 2 or 3...I start seeing the RadBusyIndicator doing it's thing...but the UI is still responsive.  If I do all 12...the UI is stuck for a good 10 minutes (my test database has more than 250,000 records in each table).

My source files can be found at the following blog post (If you'd rather I posted them here I can do that as well...)

Any thoughts as to what I'm doing wrong?  Thanks in advance.  :)

Stefan
Telerik team
 answered on 13 May 2016
1 answer
82 views

I have the same issue with the DataFormComboBoxField in a RadDataForm : (more detailed : http://www.telerik.com/forums/edit-lookup-values-with-dataformcomboboxfield )

Either i get the problem i first came for, either i have this one (with a GridViewComboBoxColumn or a DataFormComboBoxField):
                <telerik:GridViewComboBoxColumn Header="Retour 2"
                                                   DisplayMemberPath="Name"
                                                   DataMemberBinding="{Binding Team, Mode=TwoWay}"
                                                   ItemsSource="{Binding Paths, Source={StaticResource EscortViewModel}}"
                                                   />
With that, when i load the usercontrol, the value is not set/displayed in the column... BUT, when i change it, it calls the set of the viewmodel and update the ViewModel (so the displayed values).
What i can't find is how mix the two to display the data when the usercontrol is loaded AND update the value !
Thank you very much

Stefan
Telerik team
 answered on 13 May 2016
1 answer
83 views
I have the same issue with the DataFormComboBoxField in a RadDataForm : (more detailed : http://www.telerik.com/forums/edit-lookup-values-with-dataformcomboboxfield )

Either i get the problem i first came for, either i have this one (with a GridViewComboBoxColumn or a DataFormComboBoxField):
                <telerik:GridViewComboBoxColumn Header="Retour 2"
                                                   DisplayMemberPath="Name"
                                                   DataMemberBinding="{Binding Team, Mode=TwoWay}"
                                                   ItemsSource="{Binding Paths, Source={StaticResource EscortViewModel}}"
                                                   />
With that, when i load the usercontrol, the value is not set/displayed in the column... BUT, when i change it, it calls the set of the viewmodel and update the ViewModel (so the displayed values).
What i can't find is how mix the two to display the data when the usercontrol is loaded AND update the value !
Thank you very much
Stefan
Telerik team
 answered on 13 May 2016
4 answers
118 views

Hello!

I have a problem when using Windows8TouchTheme,

when alert in Windows8TouchTheme, the punctuations can not show incorrect.

but in windows7theme,it is all right.

 

Yana
Telerik team
 answered on 13 May 2016
2 answers
198 views
Hello,
Reading http://docs.telerik.com/devtools/wpf/controls/raddataform/how-to/raddatafor-edit-lookup-values-with-radcombobox.html
I have a viewmodel with (simplified):
Agent
    - long Id
    - string FirstName
    - Team Team
Team
   - long Id
   - string Name

In an UserControl (simplified):
<UserControl.Resources>
        <viewmodels:EscortViewModel x:Key="EscortViewModel" />
</UserControl.Resources>
<Grid x:Name="LayoutRoot" DataContext="{StaticResource EscortViewModel}">
<Grid.Resources>
            <DataTemplate x:Key="AgentEditTemplate">
                    <telerik:DataFormDataField Label="Last Name" DataMemberBinding="{Binding LastName, Mode=TwoWay}" Grid.Row="0" Grid.Column="1"/>
                    <telerik:DataFormComboBoxField Label="Team"
                                                   SelectedValuePath="Id"
                                                   DisplayMemberPath="Name"
                                                   Grid.Row="2" Grid.Column="1"
                                                   DataMemberBinding="{Binding Team.Id, Mode=TwoWay}"
                                                   ItemsSource="{Binding Teams, Source={StaticResource EscortViewModel}}"
                                                   />
                </Grid>
            </DataTemplate>
</Grid.Resources>
        <StackPanel>
            <telerik:RadGridView x:Name="agentViewer"
                                    ItemsSource="{Binding Agents}"
                                    AutoGenerateColumns="False"
                                    RowIndicatorVisibility="Collapsed"
                                    IsReadOnly="True"
                                    >
                <telerik:RadGridView.Columns>
                    <telerik:GridViewToggleRowDetailsColumn />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName, Mode=OneWay}" Header="Name" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Team.Name, Mode=OneWay}" Header="Team" />
                </telerik:RadGridView.Columns>
                <telerik:RadGridView.RowDetailsTemplate>
                    <DataTemplate>
                        <Grid Background="DarkGray">
                        <Grid Margin="15">
                            <telerik:RadDataForm x:Name="agentDataEdit"
                                                    CurrentItem="{Binding}"
                                                    Header="Edit agent:"
                                                    AutoGenerateFields="False"
                                                    EditTemplate="{StaticResource AgentEditTemplate}"
                                                    ReadOnlyTemplate="{StaticResource AgentEditTemplate}"
                                                    NewItemTemplate="{StaticResource AgentEditTemplate}"
                                                    >
                                </telerik:RadDataForm>
                        </Grid>
                        </Grid>
                    </DataTemplate>
                </telerik:RadGridView.RowDetailsTemplate>
            </telerik:RadGridView>
                <Grid Background="DarkGray" x:Name="panelAddNew">
                    <Grid Margin="15">
                        <telerik:RadDataForm x:Name="agentDataNew"
                                                    Header="Add agent:"
                                                    AutoGenerateFields="False"
                                                    EditTemplate="{StaticResource AgentEditTemplate}"
                                                    ReadOnlyTemplate="{StaticResource AgentEditTemplate}"
                                                    NewItemTemplate="{StaticResource AgentEditTemplate}"
                                                    ItemsSource="{Binding Agents}"
                                                    >
                        </telerik:RadDataForm>
                    </Grid>
                </Grid>
        </StackPanel>
</Grid>

Almost everything works great. In the complete form, i can edit string, long and enum (with DataFormComboBoxField). What i can't do is the binding with the Agent.Team.Id.
In fact, the value from DB is displayed (team "A" or "B"...) but when i edit the form and change the Team (list displayed in the DataFormComboBoxField), it never return in the set of the Agent.Team property.
Am I missing something or did i do something wrong ? Is there a bug or an other syntax for the DataMemberBinding="{Binding Team.Id, Mode=TwoWay}" ?
I would like to not use an Agent.TeamId property but the object please.
Thank you very much.
Stefan
Telerik team
 answered on 13 May 2016
1 answer
124 views

I would like to set the selected PageSize when showing RadDiagramPrintPreview. How can I I achieve that as the PageInfo.PageSize property of RadDiagramPrintPreview is read only?

 

My diagram page size is set to Tabloid but when I lunch RadDiagramPrintPreview for my diagram the selected PageSize is set to letter.

Dinko | Tech Support Engineer
Telerik team
 answered on 13 May 2016
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
PasswordBox
SplashScreen
Callout
Rating
Accessibility
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?