Archive for category Telerik

_visibilityMode is null or not an object

We have an ASP.NET site that uses a plethora of Telerik controls – RadGrids, RadWindows, RadMenus, RadHamburgers – we have it all. In this case, our issue was with the RadTabStrip.

First off, it wasn’t a Telerik problem, it was an issue with our setup. We have Button controls that are global for the application, and six tabs to hold our various pages. Four of our six pages were working fine, but two of them were displaying this message when clicking on one of the application-wide buttons:

_visibilityMode is null or not an object

Cutting to the chase, the four tabs that worked had a RadWindowManager in each. So, I added one to the two tabs that were not working, and that did the trick:

<telerik:RadWindowManager ID=”RadWindowManager1″ ShowContentDuringLoad=”false” VisibleStatusbar=”false”  ReloadOnShow=”true” runat=”server”>
<windows>
<telerik:RadWindow ID=”myWindow” runat=”server” />
</windows>
</telerik:RadWindowManager>

Advertisements

Leave a comment

Disappearing paging controls in a RadGrid

I had a RadMultiPage control with the PagerStyle-AlwaysVisible property set to true.  Inside, I had several RadGrids nested in a RadPageView control. So, to recap:

<telerik:RadMultiPage PagerStyle-AlwaysVisible=”true” >
<telerik:RadPageView >
<telerik:RadGrid>
<telerik:RadGrid>
<telerik:RadGrid>

Things seemed fine, but when I would change the paging DropDownList inside the RadGrid, the pager control would disappear, and this would affect all the other RadGrids as well.

My fix for this was to remove the PagerStyle-AlwaysVisible property from the RadMultiPage control and put it in each of the RadGrid controls:

<telerik:RadMultiPage >
<telerik:RadPageView >
<telerik:RadGrid PagerStyle-AlwaysVisible=”true”>
<telerik:RadGrid PagerStyle-AlwaysVisible=”true”>
<telerik:RadGrid PagerStyle-AlwaysVisible=”true”>

As they say in France “It worked, you filthy American!”

Leave a comment

Deleting records from a Telerik RadGrid not updating the pager

When I was deleting rows from the Telerik RadGrid, the page count used for paging on the bottom left wasn’t updating. So if I had 21 records, with a setting of 10 records per page, I would see 3 pages. If I deleted 10 records, I would expect that the pages listed would be reduced to 2, but it wasn’t – it was staying at three. As Mr. Smith from Lost in Space would say, “The pain, the pain”.

My solution was to create a global page variable to hold the latest number of rows:

int currentRows  = 0;

In the function that loads the grid (creatively called LoadGrid), I added code to update the currentRows  variable with the latest count of items from the database. So whenever the count was updated, my code would detect the latest count of items:

List<MyItem> Items = GetThoseObjectsDude();
 currentRows = Items.Count;

Finally, during the Page_PreRender event, I added a check to see if the count was updated. If so, then it updated the RadGrid’s VirtualItemCount property. When the RadGrid was rebound, the page count would be updated, too:

protected void Page_PreRender(object sender, EventArgs e)
 {
 if (currentRows > 0)
 gridItems.VirtualItemCount = currentRows;
gridItems.Rebind();
currentRows = 0;
 }

1 Comment

Double binding in a RadGrid in a RadWindow. Not rad, dude.

I ran across a problem when dealing with a Telerik RadWindow. On my page, I had this definition:

<telerik:RadWindow ID=”MyWindow” runat=”server” Title=”Scott’s Window” VisibleOnPageLoad=”false” Behavior=”Close” EnableShadow=”true” Modal=”true”>
</telerik:RadWindow>

The problem is that when I opened the window, then closed it by using the “X” in the top right corner, and then opened the window again, the control would be bound twice. And not just the RadGrid I had in the control, the entire page would be duplicated.

I tried everything I could think of. I tried removing the extra control (there was one being loaded when opening the window again) in the RadWindow’s ContentContainer.Controls collection. I tried stopping the processing of the second page binding.  I tried using the DestoryOnClose property. I tried going to lunch. Nothing worked.

So I cheated.

Instead of dealing with the mysterious double binding, I just removed the “X” from the menu bar by changing the Behavior property of the RadWindow:

Behavior=”None”

This hid the close button, as well as the minimize and maximize buttons. I didn’t need them, and the users didn’t need them, and if you can’t perform the action that causes the error, you can’t cause the error.

Leave a comment

Changing the paging text of a Telerik RadGrid

I was delving into the mysteries of the Telerik RadGrid. I needed to change the paging label in the bottom right corner of the grid because of, what else, users. In our application, we have parent and child records that are bound to the grid, and by default, the child records are hidden. The users only wanted the parent records to be shown in the paging label. So if I have a total of 20 records, with 15 parents and 5 children, the count should only say 15, the full text of the pager bar being: 15 items in 1 page.

I asked for the wisdom of the Telerik forums, which were very helpful. I was given the code and told to put it into the RadGrid PreRender event. And that seemed to work, but there was a problem in that we have other code that binds to LinkButtons, and one of the buttons was being rendered improperly by the call to rebind the RadGrid.

Luckily, it wasn’t difficult to fix: I just moved the code to change the paging label to the page PreRender event instead of the RadGrid PreRender event, and that worked:

        protected void Page_PreRender(object sender, EventArgs e)
        {
            string pageLabel = pagerRowCount > PageSize ? "pages" : "page";

            GridPagerItem pagerItem = (GridPagerItem)gridOrders.MasterTableView.GetItems(GridItemType.Pager)[0];
            gridOrders.PagerStyle.PagerTextFormat = "{4} " + pagerRowCount + " items in " + " {1} " + pageLabel;
            gridOrders.Rebind();
        }

 

Leave a comment

Formatting the paging label of a Telerik RadGrid

I was encountering in issue with paging when dealing with a Telerik RadGrid. In our application, we have certain (but not all) records that can have child records. The problem was that the label would say 100 records where there were 75 parent records and 25 child records, and I wanted to just have the parent rows counted, since those were the only ones initially visible. So the label in the paging row said:

100 items in 4 pages

And I wanted it to say:

75 items in 3 pages.

(This is assuming that 25 records were being shown per page.)

Before going any farther, I have to say that the Telerik forums were a great resource. One of the Telerik employees did a great job of answering my questions, without which I probably couldn’t have finished this.

First, I declared a global page counter to hold the parent records:

int pagerRowCount = 0;

In the RadGrid’s NeedDataSource event, I wrote the code to count the number of parent lines. I was able to do this because our CustLineItem object had a property called hasChildRecords to determine if there were child records:

LinePager<CustLineItem> pager = new LinePager<CustLineItem>(Items);

foreach (CustLineItem item in Items)
{
    if (custLineNum.hasChildRecords == true)
        pagerRowCount++;
}

(The LinePager class is declared at public class LinePager <T>, and has an internal property declared as an IList<t> to hold the list of object used for paging. Items is a collection of object populated from the database.)

In the RadGrid’s PreRender event, which is called after the NeedDataSource  event,  I added the code to modify the label:

string pageLabel = pagerRowCount > SizeToDisplay ? "pages" : "page";

GridPagerItem pagerItem = (GridPagerItem)gridLineItems.MasterTableView.GetItems(GridItemType.Pager)[0];
gridLineItems.PagerStyle.PagerTextFormat = "{4} " + pagerRowCount + " items in " + " {1} " + pageLabel;
gridLineItems.Rebind();

The SizeToDisplay variable is a global property and represents the number of items to display. It defaults to 25, but can be changed by a drop list which is part of the RadGrid.

Leave a comment

Half-highlighted rows in a Telerik RadGrid

I worked on an issue where, inside a Telerik RadGrid control, we changed the background color  of rows that had an error status to red. Our normal behavior was selected rows was changing the background color to blue.  The problem was that when selecting one of these rows in error, the line would split – half would be red, and half would be blue. Not attractive.

Blessed be the Telerik forums, for they led me to write this little snippet of code.

<style type="text/css">
    div.RadGrid_Windows7 .rgSelectedRow  
    {
        background: none #D6EBFF;
    }
 </style>

For the longest time, I couldn’t get the issue working, but as the blog post mentions, I put the “div” in front of the style, and that was the key. Once I did that, the style had precedence and it worked!

Leave a comment