Telerik Forums
UI for WPF Forum
0 answers
184 views
Hi,

I've recently begun working on my first WPF application using Telerik's RadControls and I've run into a problem which I am unable to solve. I have a main RadGridView which has multiple levels of nested RadGridViews (3 nested gridviews in total). Each nested GridView relies on information from the parent in order to populate the columns and I do so by binding a method to the LoadingRowDetails event and pass that information to my ViewModel. When the nested gridview attempts to load the ObservableCollection, its Get method uses the retrieved information in order to execute an SQL query on the DB and populate the collection. 

My problem is that for some reason when I attempt to bind a method to the 3rd nested RadGridView, instead of working as the parents do, it throws an NullReferenceException (it doesn't even reach the method) upon attempting to expand just the first row.
I've read and searched everywhere for a solution, but to no avail.

I unfortunately cannot share my actual code, since my company prohibits it, but I hope this example is clear enough to perhaps allow for a solution.

<Grid>   
    <telerik:RadGridView x:Name="Tools" Marin="0" LoadingRowDetails="ToolsLoadingRowDetails" ItemsSource="{Binding Tools}" IsReadOnly="True" RowHeight="45" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" CanUserFreezeColumns="False" CanUserResizeColumns="True" ShowGroupPanel="False">
        <telerik:RadGridView.Columns>
            <telerik:GridViewToggleRowDetailsColumn />
            <telerik:GridViewDataColumn Header="Product Id" DataMemberBinding="{Binding Path=TypeOfTool}" Width="*"/>
            <telerik:GridViewDataColumn Header="Target market" DataMemberBinding="{Binding Path=TargetMarket}" Width="3*"/>
           </telerik:RadGridView.Columns>
           <telerik:RadGridView:RowDetailsTemplate>
               <DataTemplate>
                   <telerik:RadGridView  Marin="0" LoadingRowDetails="MoreInfoLoadingRowDetails" ItemsSource="{Binding Path=DataContext.MoreInfo, RelativeSource={RelativeSource AncestorType={x:Type telerik:RadGridView}}}" IsReadOnly="True" RowHeight="45" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" CanUserFreezeColumns="False" CanUserResizeColumns="True" ShowGroupPanel="False">
                       <telerik:RadGridView.Columns>
                           <telerik:GridViewToggleRowDetailsColumn />
                           <telerik:GridViewDataColumn Header="More Info" DataMemberBinding="{Binding Path=MoreInfo}" Width="*"/>
                       </telerik:RadGridView.Columns>
                          <DataTemplate>
                               <telerik:RadGridView Marin="0" LoadingRowDetails="DetailedInfoLoadingRowDetails" ItemsSource="{Binding Path=DataContext.DetailedInfo, RelativeSource={RelativeSource AncestorType={x:Type telerik:RadGridView}, AncestorLevel=2}}" IsReadOnly="True" RowHeight="45" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" CanUserFreezeColumns="False" CanUserResizeColumns="True" ShowGroupPanel="False">
                                   <telerik:RadGridView.Columns>
                                       <telerik:GridViewToggleRowDetailsColumn />
                                      <telerik:GridViewDataColumn Header="Detailed Info" DataMemberBinding="{Binding Path=DetailedInfo}" Width="*"/>
                                   </telerik:RadGridView.Columns>
                                       <DataTemplate>
                                           <telerik:RadGridView Marin="0" LoadingRowDetails="TargetInfoLoadingRowDetails" ItemsSource="{Binding Path=DataContext.TargetInfo, RelativeSource={RelativeSource AncestorType={x:Type telerik:RadGridView}, AncestorLevel=3}}" IsReadOnly="True" RowHeight="45" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" CanUserFreezeColumns="False" CanUserResizeColumns="True" ShowGroupPanel="False">
                                               <telerik:RadGridView.Columns>
                                                  <telerik:GridViewToggleRowDetailsColumn />
                                                  <telerik:GridViewDataColumn Header="Target Info" DataMemberBinding="{Binding Path=TargetInfo}" Width="*"/>
                                   </telerik:RadGridView.Columns>
                               </telerik:RadGridView>
                           </telerik:RadGridView.RowDetailsTemplate>
                       </telerik:RadGridView>
                   </DataTemplate>
               </telerik:RadGridView.RowDetailsTemplate>
           </telerik:RadGridView>
       </DataTemplate>
   </telerik:RadGridView.RowDetailsTemplate>
</telerik:RadGridView>

Again, I just wrote this by hand so it probably contains open/close tagging errors, but the overall idea should be understood.
The problematic event to bind to is the deepest one, in the example it is the "TargetInfo" GridView. 
The XAML works as long as I don't bind to the LoadingRowDetails event. The moment I add the binding, the code throws the NullReferenceException
open attempt to expand the first row.

I hope I've provided enough information regarding the problem.

Thanks

Dave
Top achievements
Rank 1
 asked on 03 Dec 2012
6 answers
138 views
HI,

Is there a way to keep either ends of the itemsource (first and last item) as top item in the caouselpanel whenever I reached the first/last item when scrolling..

Thanks,
Jog
Jonah
Top achievements
Rank 1
 answered on 03 Dec 2012
3 answers
318 views

Hello,

I am using CellTemplateSelector to change the color of a cell depending on its value.  I found sample code on how to do this and it works well for GridViewDataColumn but I can't get it to work with GridViewExpressionColumn

 
I'm using the following and it works:


<
telerik:GridViewDataColumn DataMemberBinding= "{Binding TotalAdjRateNew}" TextAlignment="Right" Width="100" DataFormatString="{} {0:#%}" IsReadOnly="True">

    <telerik:GridViewDataColumn.Header>

        <TextBlock Text="New Total Adj %" TextWrapping="NoWrap" TextAlignment="Center" />

    </telerik:GridViewDataColumn.Header>

    <telerik:GridViewDataColumn.CellTemplateSelector>

        <telerik:ConditionalDataTemplateSelector>

            <telerik:DataTemplateRule Condition="TotalAdjRateNew &lt; 0">

                <DataTemplate>

                    <TextBlock Text="{Binding TotalAdjRateNew, StringFormat=p0}" 
                        HorizontalAlignment
="Right" Foreground="Red"/>

                </DataTemplate>

            </telerik:DataTemplateRule>
        </telerik:ConditionalDataTemplateSelector>

    </telerik:GridViewDataColumn.CellTemplateSelector>

</telerik:GridViewDataColumn>

 

However when I use the code below with a GridViewExpressionColumn  the value is not displaying.  I am not sure what the binding should be inside the DataTemplateRule.

 

<telerik:GridViewExpressionColumn UniqueName="TotalAdjPCT" TextAlignment="Right" Width="100" 
    DataFormatString
="{} {0:#%}" Expression="MAN_ADJ_PCT + MOD_ADJ_PCT" IsReadOnly="True">

     <telerik:GridViewExpressionColumn.Header>

        <TextBlock Text="Total Adj %" TextWrapping="NoWrap" TextAlignment="Center" />

    </telerik:GridViewExpressionColumn.Header>

    <telerik:GridViewExpressionColumn.CellTemplateSelector>

        <telerik:ConditionalDataTemplateSelector>

            <telerik:DataTemplateRule Condition="MAN_ADJ_PCT + MOD_ADJ_PCT &lt; 0">

                <DataTemplate>

                    <TextBlock Text="{Binding TotalAdjPCT, StringFormat=p0}" HorizontalAlignment="Right" 
                        Foreground
="Red"/>

                </DataTemplate>

            </telerik:DataTemplateRule>

        </telerik:ConditionalDataTemplateSelector>

    </telerik:GridViewExpressionColumn.CellTemplateSelector>

</telerik:GridViewExpressionColumn>

 

Yoan
Telerik team
 answered on 03 Dec 2012
14 answers
419 views
Hi everybody!

I want to provide the possibility to select multiple rows, columns and cells like in Excel. That means I need a combination of row and cell selection. Are there any demos are examples how to achieve this?

If I have to implement it myself, an event that is fired when a row or column header cell is clicked would be helpful. Does it exist?

Thanks

Uli

Alan
Top achievements
Rank 2
 answered on 03 Dec 2012
1 answer
114 views
We use several radGridViews in our project and have often included an export button to push the content of the grids to Excel. Our users love the feature.

Recently we discovered a problem when you have a combobox column.  It seems to be trying to convert the display string to the type of the column during the export.  It's difficult to explain so I have prepared a small demo of the problem:

https://www.dropbox.com/s/4zkr5ofgmyfbgtt/radGridViewErrorTest.zip

if you try to export the data it will throw an error saying that the 'String must be exactly one character long'.  For combo boxes that use an integer as the selected value instead of a char (like this example does) the message will ready 'Input string not in correct format'.

Is there a better way to do combo box columns or the export so that this error can be avoided?
Yoan
Telerik team
 answered on 03 Dec 2012
0 answers
116 views
Hi
RadPaneGroup.Items.Refresh();

when I use this code in my wpf project all of RadDocumentPane is closed.
whats the basic concept of using RadPaneGroup and RadDocumentPane?
Ahad
Top achievements
Rank 1
 asked on 03 Dec 2012
10 answers
459 views
I'm trying to build a page using the DataForm ICollectionVew Synchronization demo as an example - having a GridView and a DataForm bound to the same CollectionView.

My underlying data is an ObservableCollection of my own record objects, which are instances of a class that implements INotifyPropertyChanged and IEditableObject. This collection is populated from a database.

In my VIewModel, I construct a QueryableCollectionView from the ObservableCollection, and I bind both the GridView and the DataForm to this.  Everything seems to work fine, as I navigate through the records, both on the form and in the grid.  Changing the selected record in the form changes the selected record in the grid, and vice versa.

If I edit a record in the form, the changes appear immediately in the grid, and if I hit cancel in the form, they immediately revert to what they were, in the grid.  (Which indicates that the ICollectionView.EditCancel is working right).

I have a CollectionChanged handler listening for changes in the QueryableCollectionView.  When I click on Delete, it sees a NotifyCollectionChangedAction.Remove, and deletes the record from the database.  And this seems to be working fine.

When I click "Add", I see a new row in the GridView, blank fields in the DataForm, and the CollectionChanged handler sees a NotifyCollectionChangedAction.Add, and is passed an empty instance of the record.  All it does then is populate the fields in the record that aren't visible in the GridView or the DataForm.  Later, when the user hit's the "OK" button on the DataForm, the ICollectionView.EditEnd method on the record is called - which does an insert or an update to put the record into the database.

And here's where things go wrong.  The new row in the GridView stays highlighted, like the grid thinks it's still being edited.  And while if I navigate to next and previous records in the DataForm, I see the selected row in the grid changing, if I change the selected row in the grid, I do not see the DataForm updated with the newly-selected record.

Something is not quite right, and I'm at a loss as to where to look.

Any ideas?
Maya
Telerik team
 answered on 03 Dec 2012
0 answers
106 views
Solved, was using wrong property.

Hi,

Event though I have set the WeekGroupHeaderStringFormat property to {}{0:dddd(MM/dd/yy)} it does not appear to affect the header which remains as i.e. 01 Monday. I just wish to have the names of the days displayed as Monday to Sunday without date numbers but seem to be failing, although changing firstDayOfWeek does seem to have an effect. Can anyone help?

<telerik:RadScheduleView Name="_scheduleView"
                                 AppointmentsSource="{Binding Appointments}"
                                 Grid.Row="5"
                                 Grid.ColumnSpan="2"
                                 CurrentDate="2012-10-01"
                                 NavigationHeaderVisibility="Collapsed"
                                 MinAppointmentWidth="10"
                                 MinAppointmentHeight="5"
                                 ShowDialog="RadScheduleView_ShowDialog"
                                 ToolTipTemplate="{StaticResource AppointmentToolTipTemplate}"
                                 telerik:StyleManager.Theme="Metro">
            <telerik:RadScheduleView.ViewDefinitions>
                <telerik:WeekViewDefinition FirstDayOfWeek="Monday"
                                            WeekGroupHeaderStringFormat="{}{0:dddd(MM/dd/yy)}">
                </telerik:WeekViewDefinition>
            </telerik:RadScheduleView.ViewDefinitions>
        </telerik:RadScheduleView>
Daniel
Top achievements
Rank 1
 asked on 03 Dec 2012
1 answer
74 views
I am after a view, like weekview. However only shows every Friday. 

so it may show every friday, for 7 fridays .

I have no idea where to start. 
Yana
Telerik team
 answered on 03 Dec 2012
0 answers
84 views
Hi ,

i have deleted a value in radgridview cell and moved to another cell still the value is showing in old cell. can you please tell me what i need to do to resolve this?

i am using this control for WPF applications.
Ravindra
Top achievements
Rank 1
 asked on 03 Dec 2012
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
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?