This is a migrated thread and some comments may be shown as answers.

NoDataString

8 Answers 71 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Steven Hillaert
Top achievements
Rank 1
Steven Hillaert asked on 13 Aug 2010, 09:57 AM
Hi,

Is there a possibility to have some kind of "NoDataString" on the GridView as in the Chart control?


Thanks,
Steven Hillaert

8 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 13 Aug 2010, 12:18 PM
Hi Steven Hillaert,

Yes, it is possible. Please check this blog post:

Empty data template in RadGridView for Silverlight (and WPF)

Greetings,
Veselin Vasilev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Steven Hillaert
Top achievements
Rank 1
answered on 13 Aug 2010, 01:41 PM
Thanks for the quick reply but I can't get it to work.

1. I first got the IndexOutOfRange exception, I used the fix in the comments on the post:
Remark: the code inside the "if" statement is never executed
private void LoadTemplateIntoGridView(RadGridView gridView)
        {

            contentPresenter.IsHitTestVisible = false;
            contentPresenter.DataContext = this;
            contentPresenter.ContentTemplate = this.EmptyDataTemplate;

            if (gridView.ChildrenOfType<Grid>().Count > 0)
            {
                Grid rootGrid = gridView.ChildrenOfType<Grid>()[1];

                contentPresenter.SetValue(Grid.RowProperty, 2);
                contentPresenter.SetValue(Grid.RowSpanProperty, 2);
                contentPresenter.SetValue(Grid.ColumnSpanProperty, 2);
                contentPresenter.SetValue(Border.MarginProperty, new Thickness(0, 27, 0, 0));
                rootGrid.Children.Add(contentPresenter);
            }
        }

2. This is the XAML of the grid:
<telerikGridView:RadGridView Width="400" Grid.Row="1" Grid.Column="0" x:Name="RadGridView1" CanUserFreezeColumns="False" ItemsSource="{Binding Counters}"  IsReadOnly="True" AutoGenerateColumns="False"
                         ShowGroupPanel="False" ShowColumnHeaders="False" RowIndicatorVisibility="Collapsed"
                         SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                         SelectionChanged="RadGridView1_SelectionChanged"
                         telerikDragDrop:RadDragAndDropManager.AllowDrag="True"
                         telerikDragDrop:RadDragAndDropManager.AllowDrop="True" FontFamily="Courier New">

    <i:Interaction.Behaviors>
        <b:EmptyDataTemplateBehavior>
            <b:EmptyDataTemplateBehavior.EmptyDataTemplate>
                <DataTemplate>
                    <TextBlock Text="Drop/double-click a station or open a file." HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="{Binding MessageVisibility}" />
                </DataTemplate>
            </b:EmptyDataTemplateBehavior.EmptyDataTemplate>
        </b:EmptyDataTemplateBehavior>
    </i:Interaction.Behaviors>

   
    <telerikGridView:RadGridView.SortDescriptors>
        <data:SortDescriptor Member="Counter.Putm.P"/>
        <data:SortDescriptor Member="Counter.Putm.U"/>
        <data:SortDescriptor Member="Counter.Putm.T"/>
        <data:SortDescriptor Member="Counter.Putm.M"/>
    </telerikGridView:RadGridView.SortDescriptors>

    <telerikGridView:RadGridView.Columns>
        <telerikGridView:GridViewDataColumn>
            <telerikGridView:GridViewDataColumn.CellTemplate>
                <DataTemplate>
                    <CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}"/>
                </DataTemplate>
            </telerikGridView:GridViewDataColumn.CellTemplate>
        </telerikGridView:GridViewDataColumn>
        <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding Counter.Putm}" Header="PUTM" />
        <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding Counter.Mnemonic}" Header="Mnemonic" Width="*" />
    </telerikGridView:RadGridView.Columns>

</telerikGridView:RadGridView>

3. I'm using 2010 Q2 release

Am I doing something wrong or is there a bug?


Thanks,
Steven Hillaert
0
Veselin Vasilev
Telerik team
answered on 17 Aug 2010, 01:15 PM
Hello Steven Hillaert,

Actually there is one change for the latest version - you need to use

Grid rootGrid = gridView.ChildrenOfType<Grid>()[0];

Please find attached a sample working project.

Hope it helps.

Greetings,
Veselin Vasilev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Steven Hillaert
Top achievements
Rank 1
answered on 17 Aug 2010, 02:13 PM
Hi,

I just can't get it to work.

gridView.ChildrenOfType<Grid>() is always empty


Steven Hillaert
0
Veselin Vasilev
Telerik team
answered on 17 Aug 2010, 02:32 PM
Hello Steven Hillaert,

This is really strange. Here is a video on how it behaves on my machine.

Regards,
Veselin Vasilev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Steven Hillaert
Top achievements
Rank 1
answered on 17 Aug 2010, 02:38 PM
Just to be clear, your example works on my machine but in my application it just won't work, gridView.ChildrenOfType<Grid>() is always empty in my application. I even changed my GridView to resemble your grid (empty, except for the behavior).

The only differences are that I use a custom usercontrol to hold the grid and I use Prism to load the the usercontrol.


Steven Hillaert
0
Accepted
Veselin Vasilev
Telerik team
answered on 17 Aug 2010, 04:02 PM
Hi Steven Hillaert,

Can you please try with the attached updated behavior instead.

Regards,
Veselin Vasilev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Steven Hillaert
Top achievements
Rank 1
answered on 18 Aug 2010, 08:25 AM
Your new version almost works, I just had to make 2 changes:
- add using: using System.Linq
- changed line: Grid rootGrid = gridView.ChildrenOfType<Grid>()[0]; // as it's empty it still throws an exception
  into: Grid rootGrid = gridView.ChildrenOfType<Grid>().FirstOrDefault();

Thanks a lot for your help!!

Steven Hillaert
Tags
GridView
Asked by
Steven Hillaert
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Steven Hillaert
Top achievements
Rank 1
Share this question
or