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
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.
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; |
} |
} |
Regards
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.
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.
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
>
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
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
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/.