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

Center a NoRecordsTemplate?

4 Answers 234 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Xorcist
Top achievements
Rank 1
Xorcist asked on 27 Mar 2013, 06:19 PM
Is there any easy way to center (both horizontally and vertically) a NoRecordsTemplate within the body of the RadGrid when using:

<ClientSettings EnableRowHoverStyle="true">
  <Scrolling AllowScroll="true" UseStaticHeaders="true"></Scrolling>
  <Selecting AllowRowSelect="true"></Selecting>
</ClientSettings>

on a RadGrid that has a height of 100%?

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Mar 2013, 04:21 AM
Hi,

Try the following CSS.
CSS:
.rgNoRecords td
{
      text-align:center !important;
}

Thanks,
Shinu
0
Xorcist
Top achievements
Rank 1
answered on 28 Mar 2013, 01:44 PM
That will only get me horizontal. I'm using:

<ClientSettings EnableRowHoverStyle="true">
  <Scrolling AllowScroll="true" UseStaticHeaders="true"></Scrolling>
  <Selecting AllowRowSelect="true"></Selecting>
</ClientSettings>

and a grid height of 100% because I want my grid to size to the window (and that works perfectly). But I want to try and center my "No Records Found" message BOTH horizontally and vertically so it shows in the very center of the grid body.

Edit: If I change the parent table to have a height of 100% (Tested in FireFox w/ FireBug) I get the results I want, but I only want to do this when the no records template is shown... any ideas on how to achieve this?
0
Eyup
Telerik team
answered on 02 Apr 2013, 08:55 AM
Hello John,

You can try the following approach:
function pageLoad() {
    var masterEl = $find("<%= RadGrid1.ClientID %>").get_masterTableView().get_element();
    var noItemsEl = $(masterEl).find(".rgNoRecords")[0];
    if (noItemsEl) {
        masterEl.style.height = "95%";
        $(masterEl).find(".rgNoRecords").children()[0].style.textAlign = "center";
    }
}

Hope this helps. Please give it a try and let me know if it works for you.

Regards,
Eyup
the Telerik team
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 their blog feed now.
0
Xorcist
Top achievements
Rank 1
answered on 02 Apr 2013, 02:49 PM
That looks like it works, thanks.
Tags
Grid
Asked by
Xorcist
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Xorcist
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or