Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
660 views

Hello,

I am using Telerik RadControls for ASP.NET AJAX 2009.01.0527.20.

I have a RadGrid that contains a column called Status.  I am replacing the text ("1", "2", or "3") in the RadGrid1_ItemDataBound() event with a blank ("") and setting the CssClass to have the appropriate background image (i.e., background: url('images/1_green_light.gif') no-repeat center;)).  This is working fine and I have the proper image (green, yellow, or red) for the status.  I was replacing the text with "<a href="..."><img src="green.gif"...></a>" but this worked fine in IE but not always in Firefox.  Sometimes the image would show and sometimes not.  So I opted for the background image technique I described above which works fine in both browsers.
Now I want to create a custom filter for this column.  I have a RadComboBox with 3 checkboxes and the three images in the dropdown and I can check or uncheck the status(es) I want to filter on.  I have the RadComboBox setup visually just fine using a custom filter template.

The problem is that I don't know how to apply the filter in the code-behind.  What event should I hook into and how do I apply the filter?

Here is the code for my RadGrid:

<telerik:RadGrid runat="server" ID="RadGrid1"
    AllowFilteringByColumn="true" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
    Height="100%" Width="100%" PageSize="10"
    OnDataBound="RadGrid1_DataBound"
    OnItemDataBound="RadGrid1_ItemDataBound"
    OnNeedDataSource="RadGrid1_NeedDataSource"
    OnPreRender="RadGrid1_PreRender"
    OnItemCommand="RadGrid1_ItemCommand"
    >
    <ClientSettings EnableRowHoverStyle="true">
        <Resizing AllowColumnResize="true" ClipCellContentOnResize="true" EnableRealTimeResize="true" />
        <Selecting AllowRowSelect="true" />
        <Scrolling AllowScroll="true" UseStaticHeaders="true" />
    </ClientSettings>
  
    <MasterTableView AllowPaging="true" TableLayout="Fixed">
        <Columns>
            <telerik:GridBoundColumn DataField="Status" AllowFiltering="true" FilterControlWidth="32px"
                HeaderText="Status" SortExpression="Status" UniqueName="Status">
                <HeaderStyle Width="56px" />
                <ItemStyle HorizontalAlign="Center" />
                <FilterTemplate>
                    <telerik:RadComboBox runat="server" ID="RadComboBox1" HighlightTemplatedItems="true" Width="32">
                        <Items>
                            <telerik:RadComboBoxItem Text="" Count="1" Info="All needed updates installed"            Image="images/1_green_light.gif" />
                            <telerik:RadComboBoxItem Text="" Count="2" Info="Some updates pending install or unknown" Image="images/2_yellow_light.gif" />
                            <telerik:RadComboBoxItem Text="" Count="3" Info="Some updates failed"                     Image="images/3_red_light.gif" />
                        </Items>
                        <ItemTemplate>
                            <div onclick="StopPropagation(event)" class="combo-item-template">
                                <asp:CheckBox runat="server" ID="chk1" Checked="true" onclick="onCheckBoxClick(this)"/>
                                <asp:Label runat="server" ID="Label1" AssociatedControlID="chk1">
                                    <span class="NoWrap">
                                        <img id="img<%# DataBinder.Eval(Container, "Attributes['Count']") %>"
                                                src="<%# DataBinder.Eval(Container, "Attributes['Image']") %>"
                                                alt="<%# DataBinder.Eval(Container, "Attributes['Info']") %>" />
                                        <%# DataBinder.Eval(Container, "Attributes['Info']")%></span></asp:Label>
                            </div>
                        </ItemTemplate>
                    </telerik:RadComboBox>
                    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                        <script type="text/javascript" language="javascript">
                            function onCheckBoxClick(chk)
                            {
                                var combo  = $find('<%# ((GridItem)Container).FindControl("RadComboBox1").ClientID  %>');
                                var text   = "";
                                var values = "";
  
                                // Get the collection of all items.
                                var items = combo.get_items();
  
                                // Enumerate all items.
                                for (var i = 0; i < items.get_count(); i++)
                                {
                                    // Get the checkbox element of the current item.
                                    var chk1 = $get(combo.get_id() + "_i" + i + "_chk1");
                                    if (chk1.checked)
                                    {
                                        var item = items.getItem(i);
                                        var info = item.get_attributes().getAttribute("Info");
                                        text   += info + ",";
                                        values += item.get_value() + ",";
                                    }
                                }
  
                                // Remove the last comma from the string.
                                text   = removeLastComma(text);
                                values = removeLastComma(values);
                                $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Status," + text );
                            }
  
                            // This method removes the ending comma from a string.
                            function removeLastComma(str)
                            {
                                return str.replace(/, $/, "");
                            }
  
                            function StopPropagation(e)
                            {
                                // Cancel bubbling.
                                e.cancelBubble = true;
                                if (e.stopPropagation)
                                {
                                    e.stopPropagation();
                                }
                            }
                        </script>
                    </telerik:RadScriptBlock>
                </FilterTemplate>
            </telerik:GridBoundColumn>
  
            <telerik:GridBoundColumn DataField="DNSName" AllowFiltering="true" FilterControlWidth="150px"
                HeaderText="Computer Name" Resizable="true" SortExpression="DNSName" UniqueName="DNSName">
                <HeaderStyle Width="190px" />
            </telerik:GridBoundColumn>
  
            <telerik:GridBoundColumn DataField="IPAddress" AllowFiltering="true" FilterControlWidth="60px"
                HeaderText="IP Address" SortExpression="IPAddressNumeric" UniqueName="IPAddress">
                <HeaderStyle Width="88px" />
            </telerik:GridBoundColumn>
  
            <telerik:GridBoundColumn DataField="CountInstalled" AllowFiltering="true" FilterControlWidth="34px"
                HeaderText="Installed" SortExpression="CountInstalled" UniqueName="CountInstalled">
                <HeaderStyle HorizontalAlign="Center" Width="66px" />
                <ItemStyle HorizontalAlign="Center" />
            </telerik:GridBoundColumn>
  
            <telerik:GridBoundColumn DataField="CountNeeded" AllowFiltering="true" FilterControlWidth="34px"
                HeaderText="Needed" SortExpression="CountNeeded" UniqueName="CountNeeded">
                <HeaderStyle HorizontalAlign="Center" Width="63px" />
                <ItemStyle HorizontalAlign="Center" />
            </telerik:GridBoundColumn>
  
            <telerik:GridBoundColumn DataField="CountNotNeeded" AllowFiltering="true" FilterControlWidth="34px"
                HeaderText="Not Needed" SortExpression="CountNotNeeded" UniqueName="CountNotNeeded"
                >
                <HeaderStyle HorizontalAlign="Center" Width="70px" />
                <ItemStyle HorizontalAlign="Center" />
            </telerik:GridBoundColumn>
  
            <telerik:GridBoundColumn DataField="CountFailed" AllowFiltering="true" FilterControlWidth="34px"
                HeaderText="Failed" SortExpression="CountFailed" UniqueName="CountFailed">
                <HeaderStyle HorizontalAlign="Center" Width="56px" />
                <ItemStyle HorizontalAlign="Center" />
            </telerik:GridBoundColumn>
  
            <telerik:GridBoundColumn DataField="CountUnknown" AllowFiltering="true" FilterControlWidth="34"
                HeaderText="Unknown" SortExpression="CountUnknown" UniqueName="CountUnknown">
                <HeaderStyle HorizontalAlign="Center" Width="72px" />
                <ItemStyle HorizontalAlign="Center" />
            </telerik:GridBoundColumn>
  
            <telerik:GridBoundColumn DataField="DaysAgo" AllowFiltering="true" FilterControlWidth="70px"
                HeaderText="Last Contact" SortExpression="DaysAgoNumeric" UniqueName="DaysAgo">
                <HeaderStyle HorizontalAlign="Center" Width="90px" />
                <ItemStyle HorizontalAlign="Center" />
            </telerik:GridBoundColumn>
  
            <telerik:GridBoundColumn DataField="ResponsiblePerson" AllowFiltering="true" FilterControlWidth="50px"
                HeaderText="PID" SortExpression="ResponsiblePerson" UniqueName="ResponsiblePerson">
                <HeaderStyle Width="70px" />
            </telerik:GridBoundColumn>
  
            <telerik:GridBoundColumn DataField="IsActive" AllowFiltering="true" FilterControlWidth="50px"
                HeaderText="State" SortExpression="IsActive" UniqueName="IsActive">
                <HeaderStyle HorizontalAlign="Center" Width="75px" />
                <ItemStyle HorizontalAlign="Center" />
            </telerik:GridBoundColumn>
  
            <telerik:GridButtonColumn ButtonType="PushButton" ButtonCssClass="TimeoutButton" CommandName="Timeout"
                HeaderText="Timeout" SortExpression="StatusButtonText" Text="Timeout" UniqueName="Timeout">
                <HeaderStyle Width="70px" />
                <ItemStyle Font-Names="Tahoma, Verdana, Sans_Serif;" Font-Size="X-Small" HorizontalAlign="Center" />
            </telerik:GridButtonColumn>
  
            <telerik:GridBoundColumn DataField="SUSClientId" UniqueName="SUSClientId" Visible="false"
                />
        </Columns>
    </MasterTableView>
  
    <PagerStyle Mode="NextPrevAndNumeric" />
</telerik:RadGrid>

Thanks in advance for any help you can provide.

Randall Price
 

Radoslav
Telerik team
 answered on 05 Aug 2010
1 answer
139 views
It doesn't seem like you can use dates for X values when adding data to series programmatically.  Is that true?

Thanks.
Giuseppe
Telerik team
 answered on 05 Aug 2010
1 answer
135 views

Hi,
i,m using radcomobox with EnableLoadOnDemand="true".

<pdi:PDIWebComboBox ID="cboMEStatus" runat="server" Width="100px" Height="110px"
                                                        MarkFirstMatch="true" OnClientDropDownOpening="GetItems"
                                                        EnableLoadOnDemand="true" EmptyMessage="Select" HighlightTemplatedItems="True"
                                                        OnItemsRequested="cboMEStatus_OnItemsRequested" DropDownWidth="220px">
                                                        <HeaderTemplate>
                                                            <table style="width: 200px" cellspacing="0" cellpadding="0">
                                                                <tr>
                                                                    <td style="width: 100px;">
                                                                        Status Description
                                                                    </td>
                                                                    <td style="width: 80px;">
                                                                        Status ID
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </HeaderTemplate>
                                                        <ItemTemplate>
                                                            <table border="0" style="width: 200px" cellspacing="0" cellpadding="0">
                                                                <tr>
                                                                    <td style="width: 100px;">
                                                                        <%# DataBinder.Eval(Container, "Text")%>
                                                                    </td>
                                                                    <td style="width: 80px;">
                                                                        <%# DataBinder.Eval(Container, "Attributes['Employee_Status_ID']")%>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </ItemTemplate>
                                                    </pdi:PDIWebComboBox>

now i,m binding radcombobox with some id coming from database and showing selected text of that id.its working fine. but my problem is "HOW TO CLEAR RADCOMOBOX"

regards
-Ravi
Simon
Telerik team
 answered on 05 Aug 2010
2 answers
93 views
hi

Very urgent please help me


i have implemented custom search in itemCommed event in my grid. but i could not execute that its getting error in "Expression expected" i checked all the possibility but i could not correct it. At the same time i implemented grouping that grouping working fine there is no issue. But searching only i have problem. please check it and let me know as soon as possible
below i pasted my c# code as well as  asp.net code

c#

 protected void RadGridMsgInbox_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        e.Canceled = true;
        Button btnG = (Button)e.Item.FindControl("btnGeneral");
        Button btnI = (Button)e.Item.FindControl("btnGeneral");
        Button btnN = (Button)e.Item.FindControl("btnGeneral");
        switch (e.CommandName)
        {
                // THIS CASE FIRE WHEN GRID SEARCH EVENT ACCOUR
            case "SearchUsersBy":
                    TextBox txtSearch = (TextBox)e.Item.FindControl("txtSearch");
                    RadioButton rdbtnFrom = (RadioButton)e.Item.FindControl("rdbtnFrom");
                    RadioButton rdbtnSubject = (RadioButton)e.Item.FindControl("rdbtnSubject");
                    ObjCC_Msg.MsgSearchStr = "";
                    if (rdbtnFrom.Checked)
                        this.RadGridMsgInbox.MasterTableView.FilterExpression = "([SentEmail] LIKE '%" + txtSearch.Text + "%')";
                    else if(rdbtnSubject .Checked )
                        this.RadGridMsgInbox.MasterTableView.FilterExpression = "( [MessageSubject] LIKE '%" + txtSearch.Text + "%' )";
                    else
                        this.RadGridMsgInbox.MasterTableView.FilterExpression = "(([MessageSubject] LIKE '%" + txtSearch.Text + "%') OR ([SENTEMAIL] LIKE '%" + txtSearch.Text + "%'))";
                  
                    if (RTbMessageMenu.SelectedIndex == 1)
                      ObjCC_Msg.GetMessage = FromMessage.Sent;
                    
                    //RadGridMsgInbox.MasterTableView.GroupByExpressions.Clear();
                    //RadGridMsgInbox.MasterTableView.Rebind();
                    RadGridMsgInbox.Rebind();
               break;
}
}

ASP.NET Code

 <CommandItemTemplate>
                                                <table cellpadding="0" cellspacing="0" border="0" width="98%">
                                                    <tr>
                                                        <td style ="width :30%">
                                                            <table border="0" cellpadding="0" cellspacing="0" width ="100%">
                                                                <tr>
                                                                    <td style ="width :90%">
                                                                        <asp:TextBox ID="txtSearch" runat="server" Width ="90%"></asp:TextBox>&nbsp;</td>
                                                                    <td style ="width :10%">
                                                                        <asp:Button ID="lnkBtnSearch" CssClass="mainSearchBtn" runat="server" Text="" CommandName ="SearchUsersBy"></asp:Button>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td colspan ="2">
                                                                        <asp:RadioButton ID="btnAll" runat ="server" Text ="All" GroupName ="Search" Checked ="true" />&nbsp;
                                                                        <asp:RadioButton ID="rdbtnFrom" runat ="server" Text ="From" GroupName ="Search" />&nbsp;
                                                                        <asp:RadioButton ID="rdbtnSubject" runat ="server" Text ="Subject" GroupName ="Search" />
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </CommandItemTemplate>

*Note: Here i attached my error screen please go through that

i am waiting for your reply
Rajiv Prashant
Top achievements
Rank 1
 answered on 05 Aug 2010
1 answer
390 views
Hi,

How do I open a radwindow from javascript, if the rad window is not contained in rad window manager.
radopen(null,windowName) opens a blank window.


Why am i not using rad window manager?

I am already using a rad window manager in my master page. I am having some windows in my content page too. Since i cannot have 2 rad window managers in my page, hence the probelm.
Princy
Top achievements
Rank 2
 answered on 05 Aug 2010
1 answer
138 views
Hi,

we're using MOSSRadEditor in a Sharepoint application. It works fine, but when a user clicks on the "link manager" tool, he can access to a "document manager" icon, which we would like to mask.

Is there a way to prevent user access to this tool ? Using the configfile.xml, or maybe in the code ?

Thanks in advance,

Daniel
Rumen
Telerik team
 answered on 05 Aug 2010
1 answer
93 views
In the newer versions the add custom color functions was reintroduced for cell and table background colors. Is it possible to store the added colors per usergroup for later usage?
Dobromir
Telerik team
 answered on 05 Aug 2010
3 answers
77 views
If I set either the HeaderStyle CssClass or the ItemStyle CssClass value the "rgSorted" class isn't being added to the column on the grid.
Daniel
Telerik team
 answered on 05 Aug 2010
1 answer
113 views
Hello, I am in the processof upgrading from vs2008 to 2010, and from Telerik Rad q3 2009 to q2 2010.
I am having this problem:
I get a message running certain parts of the app:
Could not load file or assembly 'Telerik.Web.UI, Version=2009.3.1103.25, Culture=neutral, PublicKeyToken=....4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference

However, I do not know where to look for such reference. The only place in which I can find the strings "2009.3.1103.25" is in .resx files.
How do I update them? Do I have to check them out, manually change and check in again? And do this every time I upgrade Telerik controls? Hw do I avoid this?
Thanks in advance
Sebastian
Telerik team
 answered on 05 Aug 2010
1 answer
159 views
I have a tabstrip control with three tabs and a validation summary control .
Second tab in the tabstrip has a user control with required field validators.
When I load the page it loads with the first tab . if the user make changes and if they save changes without even going to the second tab, the page blows up with the error message "Can't move focus to the control because it is invisble,not enables, or of a type that doesn't accept focus"
If I click okay the page reloads with the validation summary.

I want the page to show the validation when I hit the save and open the tab which has error .

I tried turning off the causesvalidation in the tabstrip, didn't work.

thanks
T. Tsonev
Telerik team
 answered on 05 Aug 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?