No records text in RadGridView without using behaviors

4 posts, 0 answers
  1. Ganesh Shivshankar
    Ganesh Shivshankar avatar
    78 posts
    Member since:
    Sep 2009

    Posted 01 Sep 2010 Link to this post

    Requirements

    RadControls version

    2010.2.812.1040

    .NET version

    4

    Visual Studio version

    2010

    programming language

    c#

    browser support

    all browsers supported by RadControls


    PROJECT DESCRIPTION
    Most often we want to show a "No records found..." message on the grid when there are no records bound to the grid. This project demonstrates how to create a custom RadGridView to handle this.

    The custom grid takes care of
    - not showing the no records message on load on a empty grid
    - showing the "no records" message when no data is bound (probably as a result of searh results)
    - hiding the "no records" message.

    The grid has 2 dependency properties
    - HasNoRecords (bool?)
    - NoRecordsText (string)

    Of the above 2 properties, HasNoRecords needs be to bound to a bool? value in the views view model (or code behind) which identifies if there are any records. The NoRecordsText may or may not be data bound. It can even be hardcoded as below.

    Useage is as simple as below

    <NoRecordsGridView:CustomRadGrid Grid.Row="0" ItemsSource="{Binding DataItems}" AutoGenerateColumns="True" HasNoRecords="{Binding HasNoRecords}" NoRecordsText="No data found..."/>

    Please provide your feedback on this.

    Cheers,
    Ganesh
  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 01 Sep 2010 Link to this post

    Hello Ganesh Shivshankar,

    Thank you sharing this code with the community. Your Telerik points have been updated. 


    Regards,
    Milan
    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
  3. sandy
    sandy avatar
    23 posts
    Member since:
    Aug 2010

    Posted 01 Feb 2012 Link to this post

    when i run ur code am getting this error.

    The type 'CustomRadGrid' was not found. [Line: 10 Position: 168].

    in my application am added the norecordsgridview namespace and customradgrid class file also.
    am getting the property content is set more then once error for this line.
    here am sending my code.

    <telerik:RadGridView x:Name="rgvMeterReads" ItemsSource="{Binding Data}" HorizontalAlignment="Left" Grid.Column="0" Grid.Row="0" Margin="0,0,0,0" ShowGroupPanel="False" AlternateRowBackground="#FFFF66" AlternationCount="2" ShowColumnHeaders="True" RowIndicatorVisibility="Collapsed" RowHeight="15" Width="1000" Height="auto">
                              
                                <telerik:RadGridView.Resources>
                                    <Style TargetType="telerik:GridViewHeaderCell">
                                        <Setter Property="Background" Value="Transparent"/>
                                        <Setter Property="Foreground" Value="Black" />
                                        <Setter Property="BorderBrush" Value="Blue"/>
                                    </Style>
                                </telerik:RadGridView.Resources>
                                <telerik:RadGridView.HeaderRowStyle>
                                    <Style TargetType="telerik:GridViewHeaderRow">
                                        <Setter Property="Background" Value="#66CCFF" />
                                    </Style >
                                </telerik:RadGridView.HeaderRowStyle>
                            </telerik:RadGridView>

                        <NoRecordsGridView:CustomRadGrid Grid.Row="0" ItemsSource="{Binding DataItems}" AutoGenerateColumns="True" HasNoRecords="{Binding HasNoRecords}" NoRecordsText="No data found..."/>
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 26 Dec 2012 Link to this post

    Hi,

    I have modified the project slightly and update it with the latest binaries. You can find it attached.

    Kind regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top