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

No data display with ShowHeadersWhenNoRecords="False" and GridClientDeleteColumn

11 Answers 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ManniAT
Top achievements
Rank 2
ManniAT asked on 09 Mar 2009, 03:37 PM
Hi,

I have a grid and it works OK.
Then I had the idea that it would look better if I remove the headers when no data is displayed.
The problem - when I set 

ShowHeadersWhenNoRecords

 

="False"

 

it does allways show the NoRecordsTemplate (even if data is present) - and no data is displayed.
Data is bound to a linq datasource.

When I remove my GridClientDeleteColumn it works like expected.
But this column seems to break the thing.

To reproduce - buil a simple grid, set ShowHeadersWhenNoRecords="False".
Should work as expected.
Add a GridClientDeleteColumn -- it displays always "No records to display"


Regards

Manfred

11 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 12 Mar 2009, 07:38 AM
Hi Manfred,

Indeed, the described behavior is observed. I have alerted our developers, and they will soon investigate the issue in greater detail.
I hope the problem will be addressed shortly.

Greetings,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
ManniAT
Top achievements
Rank 2
answered on 12 Mar 2009, 10:23 AM

Just because I'm curious - is the telerik-points system still active?
I remeber in the last years customers got some if they find something - my last have been assigned in december.

By the way - I made a simple work around for this - bind to the DataBound event of the grid and do something like this:

    protected void rgCartLines_DataBound(object sender, EventArgs e) {  
            if (rgCartLines.MasterTableView.DataKeyValues.Count <1) {  
                rgCartLines.ShowFooter = false;  
                rgCartLines.ShowHeader = false;  
            }  
        }  
 
rgCartLine of course is the id of the grid :)

Regards

Manfred
0
Yavor
Telerik team
answered on 16 Mar 2009, 11:24 AM
Hi Manfred,

I have updated your Telerik points for your report.
I hope the work-around you have come up meets your requirements well, while this issue is addressed.

Kind regards,
Yavor
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Bent
Top achievements
Rank 2
answered on 05 Apr 2009, 01:23 PM
What's the news on this issue? It's not fixed in the latest release (Q1 402).
0
Yavor
Telerik team
answered on 06 Apr 2009, 12:51 PM
Hi Kenneth,

Unfortunately, the issue is still not addressed. I hope this will be done in the next couple of weeks. I will update this thread when the problem is fixed.

Regards,
Yavor
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Susan Hessler
Top achievements
Rank 1
answered on 22 Mar 2010, 12:39 AM
What's the news on this issue?  And, it also happens with the detailed tables (in my case, the detailed tables do not have a delete column).
0
Brian
Top achievements
Rank 1
Veteran
answered on 09 Jul 2020, 01:27 PM

Has this been addressed yet? I have a same issue where the NoRecordsTemplate shows. There are a few things to point out here. Its not really the template that is the issue, it seems its the logic behind showing "NoDetailRecordsText" and "NoMasterRecordsText" for the grid.

If i set both properties ie:  NoDetailRecordsText="No details" NoMasterRecordsText="No master" and using NeedDataSource for my binding and GroupExpressions. This is the oddity, the "NoMasterRecords" and "NoDetailRecordsText" DO NOT show when i have data, which is good. I can not see it at the bottom of the data. However, if i use the collapse arrow on the Group, it appears at the bottom of the collapsed Group. Once I open it back up, it is there now at the bottom. This is all Client side, no postbacks. The NoRecordsTemplate works the same way. I see if AFTER i open back up the collapse. No scrolls, i have this at 100% height

 

<telerik:RadGrid runat="server" ID="RadGridAttendees" ShowHeader="true" ShowFooter="True" AutoGenerateColumns="false"
                                        EnableGroupsExpandAll="true" AllowSorting="true" AllowAutomaticUpdates="true" RenderMode="Lightweight">
 
<ExportSettings OpenInNewWindow="true" IgnorePaging="true" ExportOnlyData="true" FileName="Event Attendees" UseItemStyles="false">
                                            <Csv ColumnDelimiter="Comma" FileExtension=".csv" RowDelimiter="NewLine" />
                                            <Pdf PageBottomMargin="6.35" PageTopMargin="6.35" PageLeftMargin="6.35" PageRightMargin="6.35" ForceTextWrap="false" DefaultFontFamily="Arial Unicode MS" />
                                        </ExportSettings>
                                        <HeaderContextMenu EnableTheming="True">
                                            <CollapseAnimation Duration="400" Type="OutCubic" />
                                        </HeaderContextMenu>
                                        <ClientSettings AllowExpandCollapse="true" AllowGroupExpandCollapse="true" EnableAlternatingItems="false">
                                            <Selecting CellSelectionMode="SingleCell" />
                                            <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                                            <ClientEvents OnHeaderMenuShowing="OnHeaderMenuShowing" OnCellSelected="OnCellSelected" OnBatchEditOpening="OnBatchEditOpening" OnBatchEditCellValueChanging="OnBatchEditCellValueChanging" OnGroupExpanded="ExpandResize" OnHierarchyExpanded="ExpandResize" />
                                        </ClientSettings>
 
                                        <GroupingSettings RetainGroupFootersVisibility="true" GroupByFieldsSeparator="" CaseSensitive="false" />
 
                                        <MasterTableView runat="server" DataKeyNames="FamilyId, MemberId, EventNoteId, GroupName, NotAttending, Attending, IsPrimary, IsParent, IsChild, Questions" AllowSorting="true" EnableHeaderContextMenu="true" CommandItemDisplay="Top" GroupLoadMode="Client"
                                            ShowGroupFooter="true" ClientDataKeyNames="FamilyId, MemberId, EventNoteId, EventMasterId, EventSubId, GroupName"
                                            EditMode="Batch" NoDetailRecordsText="No details" NoMasterRecordsText="No master">                                           
 
                                            <CommandItemSettings ShowAddNewRecordButton="false" ShowExportToCsvButton="true" ShowExportToExcelButton="true" ShowExportToPdfButton="true" ShowExportToWordButton="true"
                                                SaveChangesText="Save Event Notes Changes" CancelChangesText="Cancel Event Note Changes" ShowRefreshButton="false" />
 
                                            <BatchEditingSettings EditType="Cell" />
                                             
                                            <GroupByExpressions>
                                                <telerik:GridGroupByExpression>
                                                    <GroupByFields>
                                                        <telerik:GridGroupByField FieldName="EventSubId" />
                                                        <telerik:GridGroupByField FieldName="GroupLevel" />
                                                    </GroupByFields>
                                                    <SelectFields>
                                                        <telerik:GridGroupByField FieldName="EventSubName" HeaderText=" " HeaderValueSeparator=" " />
                                                        <telerik:GridGroupByField FieldName="GroupName" HeaderText=" for Tribe: " HeaderValueSeparator=" " />
                                                    </SelectFields>
                                                </telerik:GridGroupByExpression>
                                            </GroupByExpressions>
 
                                             
 
                                            <Columns>

 

 

 

0
Brian
Top achievements
Rank 1
Veteran
answered on 09 Jul 2020, 01:38 PM
I would also like to note that i had to put code in the "NeedDataSource" event to get back a record count to use the NoRecordsTemplate correctly. If the DataSource came back empty, then i would enable the EnableNoRecordsTemplate property, if i have records in the DataSource, then disable EnableNoRecordsTemplate. Again, this was done all on the server side using the NeedDataSource. This should not be needed, as the Grid should know if it has records or not. Correct?
0
Attila Antal
Telerik team
answered on 14 Jul 2020, 08:39 AM

Hi Brian,

Due to the low demand, this issue has not been prioritized yet.

In the markup you shared columns and detail tables are not visible. Can please share the entire markup including the columns and detail tables so that I can see the complete structure? I need that information to be able to replicate the problem locally and then I can start debugging it.

Kind regards,
Attila Antal
Progress Telerik

0
Franz
Top achievements
Rank 1
Iron
answered on 20 Jun 2021, 06:54 PM

Hi,

I am using ShowHeadersWhenNoRecords="False" and in my pageLoad my RadGrid.Datasource is New object[]{} to display noRecordsTemplate. When I press a button, I am setting the RadGrid.Datasource with null  then call Rebind() to call needDataSource  but the records are not displayed neither the Headers in the UI. Whats the problem? 

PD. The radgrid is not using DataSourceID. Only NeedDataSource which validates if my static object list contains more than zero then sets my list as radgrid.datasource

0
Attila Antal
Telerik team
answered on 23 Jun 2021, 02:28 PM

Hello Franz,

Binding RadGrid correctly is essential. If not doing that, you might experience problems similar to what you have described.

1. Simple data-binding (Not recommended)

This is only working for displaying data in the Grid. Functionalities not supported by it are:

  • Inserting, deleting, and updating records through custom edit forms (WebUserControl or FormTemplate)
  • Grouping
  • Hierarchy relations
  • Filtering
  • Sorting
  • Paging

Binding in the Page Load

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        RadGrid1.DataSource = new DataTable();
        RadGrid1.DataBind();
    }
}

 

Binding In a button click

protected void RadButton1_Click(object sender, EventArgs e)
{
    RadGrid1.DataSource = new DataTable();
    RadGrid1.DataBind();
}

 

2. Using the NeedDataSource Event (Recommended)

This binding technique supports all functionalities, but there is a rule to it: Never call the DataBind() method. If you need to refresh the Grid, use the Rebind() instead.

Binding data in the NeedDataSource event. Note that DataBind() and Rebind() method will both make the Grid fire the NeedDataSource event, and so, calling any of these methods in this event will cause an infinite loop crashing the application. Try to avoid that.

protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    (sender as RadGrid).DataSource = new DataTable();
}

 

Binding/changing data on a Button Click. Assign the new data source and refresh the Grid.

protected void RadButton1_Click(object sender, EventArgs e)
{
    RadGrid1.DataSource = new DataTable();
    RadGrid1.Rebind();
}

 

I suggest that you Go with Option 2. I would recommend that technique over anything, even if you are only displaying data.

 

Here is an example with the ShowHeadersWhenNoRecords property enabled

<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="800px" OnNeedDataSource="RadGrid1_NeedDataSource">
    <MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID" ShowHeadersWhenNoRecords="true">
        <Columns>
            <telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32"
                FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
                ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
            </telerik:GridBoundColumn>
            <telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime"
                FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
                SortExpression="OrderDate" UniqueName="OrderDate">
            </telerik:GridDateTimeColumn>
            <telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal"
                FilterControlAltText="Filter Freight column" HeaderText="Freight"
                SortExpression="Freight" UniqueName="Freight">
            </telerik:GridNumericColumn>
            <telerik:GridBoundColumn DataField="ShipName"
                FilterControlAltText="Filter ShipName column" HeaderText="ShipName"
                SortExpression="ShipName" UniqueName="ShipName">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="ShipCountry"
                FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
                SortExpression="ShipCountry" UniqueName="ShipCountry">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

 

Data Binding in the NeedDataSource event

protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    (sender as RadGrid).DataSource = new DataTable();
}

 

Result

I hope this will prove helpful.

Regards,
Attila Antal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
ManniAT
Top achievements
Rank 2
Answers by
Yavor
Telerik team
ManniAT
Top achievements
Rank 2
Bent
Top achievements
Rank 2
Susan Hessler
Top achievements
Rank 1
Brian
Top achievements
Rank 1
Veteran
Attila Antal
Telerik team
Franz
Top achievements
Rank 1
Iron
Share this question
or