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

Hiding headers for detailsTable when there is no data.

7 Answers 559 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yogendra
Top achievements
Rank 1
Yogendra asked on 24 Aug 2011, 11:56 PM
This related to my support request http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=447674

I have a hierarchical grid. The hierarchy is as follows
Specimen-->Part-->Block-->Slide

The Part table has 2 children. Tracking records and Blocks. All the grid expansion is at client side. 
Sometimes there might not be any tracking records. 
I have 2 questions 
  1. How do I hide the headers and footers (from javascript) for the details table if there is no data. 
  2. If there are no records, I bind the grid to an empty string. This displays the message 'No child records to display.'. How can I set my custom message?


I have searched the forums for this without luck. 
Please help. 

Thanks in advance
   

7 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 29 Aug 2011, 02:47 PM
Hello Yogendra,

Our system indicates that you have opened a support ticket concerning the same issue. In order to avoid duplicate posts, I suggest that we continue the communication in the support ticket.

However, I post my reply here, as it might be useful for other members of the community:
    To your questions:
  1. Please set the ShowHeadersWhenNoRecords property of the corresponding table-view to false.
  2. You can use the NoRecordsTemplate in order to define a template that will be displayed if there are no records in the assigned data-source.

Best wishes,
Mira
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Tom
Top achievements
Rank 1
answered on 16 Oct 2013, 12:33 PM
Mira - thanks for posting the solution for everyone to see.

The ShowHeadersWhenNoRecords solution does not work for me, though, because I am populating the grid through a web service. When this is set, the table has no rows on page load and the OnRowDataBound function does not have any rows to write into. I don't have a workaround at present.
0
Kostadin
Telerik team
answered on 21 Oct 2013, 08:43 AM
Hello Tom,

In this case you could simply loop through the items after they are created and set visible false to the one which does not have any data. For instance something similar like the following code snippet.
var masterTable = $find("ctl00_ContentPlaceHolder1_RadGrid1").get_masterTableView();
var items = masterTable.get_dataItems();
 
for (var i = 0; i < items.length; i++)
{
    if (items[i].get_element().children.length > 0)
    {
        items[i].set_visible(false);
    }
}


Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Tom
Top achievements
Rank 1
answered on 21 Oct 2013, 12:21 PM
Hi Kostadin -

  The display problem I have is that the empty rows show on the screen during page load while iterating through them with the OnRowDataBound function (figure 1). Once the rows are populated, the empty ones automatically disappear (figure 2). When I set ShowHeadersWhenNoRecords to false, the OnRowDataBound has no empty rows to put data into, and subsequently the grid stays empty.

Tom
0
Kostadin
Telerik team
answered on 24 Oct 2013, 08:54 AM
Hi Tom,

As far as I understand your requirement is to display the grid with all its items during the loading of the table. Note that this property is created to serve the needs of the hierarchical grid, but from the provided images I noticed that you do not use one in your case. Keep in mind that by populating the grid by using a web service the grids has been already created and the rest of the operation is completing on the client. Until finishing the populating you could not display the items of the grid and the grid will remain empty. If your requirement differs from the aforementioned suggestion, I would ask you to provide a small runnable sample where the issue could be replicated in order to investigate it further.

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Tom
Top achievements
Rank 1
answered on 24 Oct 2013, 07:09 PM
Hi Kostadin -

  What I want to have happen is to not show the empty rows while the table is being populated. It seems that, because I'm populating from a web service, there have to be empty rows that show or the data cannot be put into the table. It's not a super big deal, and I can live with it as is.

FWIW, my scenario is to maintain a history of user actions in the grid. The list auto-refreshes every XX seconds, so that's why I'm using a web service to populate the table. This is not a big enough problem that I have time to build a standalone solution, but thanks for the offer.

Tom
0
Kostadin
Telerik team
answered on 29 Oct 2013, 08:54 AM
Hi Tom,

I am afraid that you could not hide the empty rows during the request. You could hide them immediately after its completion, but not during its execution.

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Yogendra
Top achievements
Rank 1
Answers by
Mira
Telerik team
Tom
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or