Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
76 views
Hello,
I am using various filters in my RadGrid, including a Google-like filter, date filter, radcombobox dropdown filters, and custom radcombobox filters which include checkboxes so the users can select multiple values.  All of these filters work fine....independently.  The problem is that if I apply my customized filter, then attempt to apply any of the other filters (which use tableView.filter to fire the command), my custom filter values are completely overwritten.

Is there anyway to keep this from happening?
Here is a sample of my code:
Default.aspx 
  
<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" 
        AllowPaging="True" AllowSorting="True" CellSpacing="0" GridLines="None" 
        Skin="WebBlue" AutoGenerateColumns="True" EnableLinqExpressions="false"
        OnPreRender="RadGrid1_PreRender" OnItemCommand="RadGrid1_ItemCommand"
        Height="620px" onneeddatasource="RadGrid1_NeedDataSource" PageSize="20" >
 <Columns>
<telerik:GridBoundColumn UniqueName="Date" DataField="Date" DataType="System.DateTime" 
                    FilterControlAltText="Filter Date column" HeaderText="Date" 
                    SortExpression="Date">
                    <FilterTemplate>
                        <telerik:RadDatePicker ID="RadDatePicker1" runat="server" ClientEvents-OnDateSelected="FromDateSelected" DbSelectedDate='<%# startDate %>'>
                        </telerik:RadDatePicker><br /><br />
                        <telerik:RadDatePicker ID="RadDatePicker2" runat="server" ClientEvents-OnDateSelected="ToDateSelected" DbSelectedDate='<%# endDate %>'>
                        </telerik:RadDatePicker>  
                        <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
                             <script type="text/javascript">
                                 function FromDateSelected(sender, args) {
                                     var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                     var ToPicker = $find('<%# ((GridItem)Container).FindControl("RadDatePicker2").ClientID %>');
  
                                     var fromDate = FormatSelectedDate(sender);
                                     var toDate = FormatSelectedDate(ToPicker);
  
                                     tableView.filter("Date", fromDate + " " + toDate, "Between");
  
                                 }
                                 function ToDateSelected(sender, args) {
                                     var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                     var FromPicker = $find('<%# ((GridItem)Container).FindControl("RadDatePicker1").ClientID %>');
  
                                     var fromDate = FormatSelectedDate(FromPicker);
                                     var toDate = FormatSelectedDate(sender);
  
                                     tableView.filter("Date", fromDate + " " + toDate, "Between");
                                 }
                                 function FormatSelectedDate(picker) {
                                     var date = picker.get_selectedDate();
                                     var dateInput = picker.get_dateInput();
                                     var formattedDate = dateInput.get_dateFormatInfo().FormatDate(date, dateInput.get_displayDateFormat());
  
                                     return formattedDate;
                                 }
                             </script>
                            </telerik:RadScriptBlock>   
                    </FilterTemplate>                       
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="WinLoss" 
                    FilterControlAltText="Filter WinLoss column" HeaderText="WinLoss" 
                    SortExpression="WinLoss" UniqueName="WinLoss">
                    <FilterTemplate>
                        <telerik:RadComboBox ID="winloss_combo" runat="server" EmptyMessage="All" AppendDataBoundItems="true" AllowCustomText="true">  
                        <Items>
                        <telerik:RadComboBoxItem runat="server" Text="" Visible="false" />
                        <telerik:RadComboBoxItem runat="server" Text="Won" />
                        <telerik:RadComboBoxItem runat="server" Text="Loss" />
                        <telerik:RadComboBoxItem runat="server" Text="Awaiting Award" />
                        <telerik:RadComboBoxItem runat="server" Text="No Bid" />
                        <telerik:RadComboBoxItem runat="server" Text="Cancelled"/>
                        </Items>                              
                            <ItemTemplate>
                            <div onclick="StopPropagation(event)">
                                   <asp:CheckBox ID="chk1" runat="server" onclick="wlClick(this)" />
                                   <asp:Label runat="server" ID="lbl1" AssociatedControlID="chk1"><%# Container.Text%></asp:Label>
                            </div>                                
                            </ItemTemplate>
                            <FooterTemplate>
                            <hr />
                            <asp:Button runat="server" ID="wlBtn" Text="Submit" CommandName="WinLossFilter"/>                            </FooterTemplate>
                        </telerik:RadComboBox>
                          
                        <telerik:RadScriptBlock ID="winloss_scriptblock" runat="server">
                             <script type="text/javascript">
                                 function wlClick(chk) {
                                     var text = ""; 
                                     var values = "";
                                     var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                     var combo = $find('<%# ((GridItem)Container).FindControl("winloss_combo").ClientID %>');
                                     //get the collection of all items 
                                     var items = combo.get_items();
                                     //enumerate all items 
                                     for (var i = 0; i < items.get_count(); i++) {
                                         var item = items.getItem(i);
                                         var skipEmptyItem = i + 1;
                                         //get the checkbox element of the current item 
                                         var chk1 = $get(combo.get_id() + "_i" + skipEmptyItem + "_chk1");
                                         if (chk1.checked) {
                                             text += item.get_text() + ",";
                                             values += item.get_value() + ",";
                                         }
                                     }
                                     //remove the last comma from the string 
                                     text = removeLastComma(text);
                                     values = removeLastComma(values);
                                     if (text.length > 0) {
                                         //set the text of the combobox
                                         combo.set_text(text);
                                     }
                                     else {
                                         //all checkboxes are unchecked
                                         //so reset the controls 
                                         combo.set_text("");
                                     }
                                     document.getElementById("<%= wltext.ClientID %>").value = text;
                                 }
                               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>
</Columns>
 </telerik:RadGrid>

Default.aspx.cs
protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                RadGrid1.DataBind();
            }
  
        }
 protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
  
            RadGrid1.NeedDataSource += new GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
  
        }
 protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
        }
 protected void RadGrid1_PreRender(object sender, System.EventArgs e)
        {
            foreach (GridFilteringItem item in RadGrid1.MasterTableView.GetItems(GridItemType.FilteringItem))
            {               
                //this maintains the appropriate checkboxes are checked and sets the value of the combo box
                RadComboBox combo = (RadComboBox)item.FindControl("winloss_combo");
                 
                foreach (RadComboBoxItem comboItem in combo.Items)
                {
                    if (wltext.Value.Contains(comboItem.Text.ToString()))
                    {
                        CheckBox chk = (CheckBox)comboItem.FindControl("chk1");
                        chk.Checked = true;
                    }
                    else
                    {
                        CheckBox chk = (CheckBox)comboItem.FindControl("chk1");
                        chk.Checked = false;
                    }
                }
                combo.Text = wltext.Value;
}
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
              
            //string filterexp = RadGrid1.MasterTableView.FilterExpression;
  
            if (e.CommandName == RadGrid.FilterCommandName)
            {
                Pair filterPair = (Pair)e.CommandArgument;
  
                switch (filterPair.Second.ToString())
                {
                    case "Date":
                        this.startDate = ((e.Item as GridFilteringItem)[filterPair.Second.ToString()].FindControl("RadDatePicker1") as RadDatePicker).SelectedDate;
                        this.endDate = ((e.Item as GridFilteringItem)[filterPair.Second.ToString()].FindControl("RadDatePicker2") as RadDatePicker).SelectedDate;
                        break;
                    default:
                        break;
                }
            }
            if (e.CommandName == "WinLossFilter")
            {
              string query = string.Empty;
            string endquery = string.Empty;
            string checkedText = string.Empty;
            if (wltext.Value != null)
                checkedText = wltext.Value;
  
            string str = "WinLoss," + checkedText;
            if (str.Split(',').Length > 2)
            {
                query = "(";
                endquery = ")";
            }
  
            query = query + "([WinLoss] = ";
            for (int i = 1; i < str.Split(',').Length; i++)
            {
                String value = str.Split(',')[i];
                int val = str.Split(',').Length;
query = query + "'" + value + "')";
                if (i < str.Split(',').Length - 1)
                {
                    query = query + " OR ([WinLoss] = ";
                }
            }
            query = query + endquery;
               RadGrid1.MasterTableView.FilterExpression = query ;
            RadGrid1.Rebind();
            }
           }

I am on a time-crunch so any assistance is appreicated!
Thanks,
Alicia
Vasil
Telerik team
 answered on 20 Jul 2011
0 answers
159 views
Hello.

I have an issue about raddatetime picker box border color.For some info; we use Webblue theme and version 2010, 3, 1109, 40 telerik dlls in our project.
When we refresh page,first of all,box border colors become black.(look attach : raddatepicker1).But after the refresh finished they looks like with normal colors (like attach : raddatepicker2)

Can you help me about this issue?
Thanks.
Ozan
Top achievements
Rank 1
 asked on 20 Jul 2011
1 answer
98 views
I'm having a problem with changing the headertext in my detailtable..
I'm creating multiple grids by a loop and show the underneath eachother..
Because the columns in my detailtable are variable, I didn't bound them..

So is there a way to change the headertext?

RadGrid[] GridName = new RadGrid[intTotalProcessTemplates];
  
        
            for (int i = 0; i < intTotalProcessTemplates; ++i)
            {
                // Create mastertable
                GridName[i] = new RadGrid();
                GridName[i].DataSource = GetDataTable("SELECT * FROM ProcessTemplate WHERE ProcessTemplate_id = " + (i + 1));
                GridName[i].MasterTableView.DataKeyNames = new string[] { "ProcessTemplate_id" };
                GridName[i].Skin = "Black";
                GridName[i].AutoGenerateColumns = false;
                GridName[i].AllowPaging = true;
  
                // Columns create
                GridName[i].MasterTableView.Columns.Add(CreateGridColumn("Process name", "Name", 10.0));
                GridName[i].MasterTableView.Columns.Add(CreateGridColumn("Process description", "Description", 80.0));
                GridName[i].MasterTableView.Columns.Add(CreateGridColumn("Parent", "Parent", 10.0));
  
                // Create detail table
                GridTableView tableViewStartProcesses = new GridTableView(GridName[i]);
                tableViewStartProcesses.DataKeyNames = new string[] { "Process_id" };
                tableViewStartProcesses.AutoGenerateColumns = true;
                tableViewStartProcesses.AllowPaging = true;
                tableViewStartProcesses.CommandItemDisplay = GridCommandItemDisplay.Top;
  
                foreach (GridColumn col in tableViewStartProcesses.RenderColumn)
                {
                    if (col.UniqueName == "templateid")
                    {
                        col.HeaderText = "Template id";
                    }
                }
  
                // Fix result from stored proc: GetAllProcessesAndSteps_SP
                LinqResult(tableViewStartProcesses, i);
  
                // Add Details to table
                GridName[i].MasterTableView.DetailTables.Add(tableViewStartProcesses);;
  
                // Add to placeholder
                this.StartProcessPlaceHolder.Controls.Add(GridName[i]);
Daniel
Telerik team
 answered on 20 Jul 2011
3 answers
86 views
hi community,

does anybody know how to update stylesheets within head-tag per ajax?

thank you for your help
bernhard
Kiara
Top achievements
Rank 1
 answered on 20 Jul 2011
1 answer
107 views
So I am using RadGrid and Client-side binding. And i am really surprise how badly it sucks. First of you you need to hack almost each column type to "GridTemplateColumn" to create Hyperlinks Columns and format data. But then you can't do the hack to export (Call the server and bind it at serverside... so stupid) it because you cant use "GridTemplateColumn" in exporting. So you are stuck with the raw data when you want to export. HOW USELESS.

Then I try to SaveSettings on the grid. AND GUEST WHAT. doenst work client side. It needs a post back and then it break the client side binding.

I almost were a Telerik "profit" but with the last week experience I feel telerik is the fast server side solution and NOT client side. Waist of time if you want to do client side.
Radoslav
Telerik team
 answered on 20 Jul 2011
7 answers
112 views
Hi,

 Iam using radscheduler version 2010 Q2, There is any possibilty to show Reminders for an appoientment even we are  not in scheduler page. i.e Display Reminder when we are in any page of Website  



Thanks 
Sanker 
Peter
Telerik team
 answered on 20 Jul 2011
4 answers
133 views
Hi Telerik,

Could you please clarify if this is expected behavior?

I am programatically setting the ForbiddenZones property of every dock on my page. I do so like this:

/// <summary>
/// Shows where docks can/can't be moved. Forbidden zones are all DockZone's with Docks.
/// </summary>
private void SynchForbiddenZones(RadDockLayout dockLayout)
{
    Logger.Info("Synching forbidden zones");
    IEnumerable<CormantRadDock> docks = dockLayout.RegisteredDocks.OfType<CormantRadDock>();
 
    foreach (CormantRadDock dock in docks)
    {
        List<string> forbiddenZones = new List<string>();
        foreach (CormantRadDock otherDock in docks.Where(otherDock => otherDock != dock && !otherDock.GetState().Closed))
        {
            forbiddenZones.Add(otherDock.DockZoneID);
            forbiddenZones.Add(otherDock.DockZoneID.Replace("RadDockZone_", "")); //Why is this necessary?
        }
        dock.ForbiddenZones = forbiddenZones.ToArray();
    }
}

I have found that there is a discrepancy between how Telerik's Client and Server code interpret ForbiddenZones. 

If I leave my forbidden zones as just "DockZoneID" then this code works fine:

function OnClientDragStart(dock) {
    var forbiddenZones = dock.get_forbiddenZones();
    for (var zoneId in forbiddenZones) {
        var zone = $find(forbiddenZones[zoneId]);
        if (zone != null) {
            var zoneElement = zone.get_element();
            Sys.UI.DomElement.addCssClass(zoneElement, "zoneDropNotOk");
        }
    }
}
 
function OnClientDragEnd(dock) {
    var forbiddenZones = dock.get_forbiddenZones();
 
    for (var zoneId in forbiddenZones) {
        var zone = $find(forbiddenZones[zoneId]);
        if (zone != null) {
            var zoneElement = zone.get_element();
            Sys.UI.DomElement.removeCssClass(zoneElement, "zoneDropNotOk");
        }
    }
}

but when I drag a dock onto an already populated dock zone, even though the zone glows red, I am still able to drop the dock onto the dock zone.

Yet, observe that if I strip of the "RadDockZone_" header -- thus making it the DockZone's UniqueName -- now the dock is unable to dock onto the dockzone in question. 

Yet, observe that if I only add the DockZone's UniqueName property to the dock's ForbiddenZone array that the above JavaScript stops functioning.

The client side appears to care about the ID of the zone, the server side cares about the UniqueName. If this is intended, why? It is a hassle to comment why I am storing two values when only one is necessary to determine uniqueness.
Pero
Telerik team
 answered on 20 Jul 2011
5 answers
218 views

Requirements

RadControls 2010.3.1317.35version

.NET version 3.5

Visual Studio version 2010

programming language C#

browser support

all browsers supported by RadControls


PROJECT DESCRIPTION
This project demonstrates how to handle ASP.NET Form Validation with the RadAjaxManager when fired from the onkeypress event from a textbox and perform an async postback if the validation succeeded.

<head runat="server">
    <title></title>
    <telerik:RadCodeBlock runat="server" ID="radCodeBlock">
        <script type="text/javascript">
            function CheckEnterKey(sender, args) {
                var keyCode = args.get_keyCode();
                if (keyCode == 13) {
                    Page_ClientValidate("Search");
                    if (Page_IsValid) {
                        var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
                        ajaxManager.ajaxRequestWithTarget('<%= btnSearch.UniqueID %>', '');
                    }
                }
            }
        </script>
    </telerik:RadCodeBlock>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="radScriptMgr">
    </telerik:RadScriptManager>
    <telerik:RadInputManager ID="RadInputManager1"  runat="server">       
        <telerik:RegExpTextBoxSetting BehaviorID="Setting3" EmptyMessage="Enter Zip Code" ClientEvents-OnKeyPress="CheckEnterKey"
            ValidationExpression="\d{5}(-\d{4})?" ErrorMessage="Invalid Zip Code" Validation-IsRequired="true" Validation-ValidationGroup="Search">
                <TargetControls>
                    <telerik:TargetInput ControlID="txtZipCode" />
                </TargetControls>
            </telerik:RegExpTextBoxSetting
    </telerik:RadInputManager>
    <telerik:RadAjaxLoadingPanel Skin="Default" runat="server" ID="pnlLoadingPanel">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="btnSearch">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="pnlSearch" LoadingPanelID="pnlLoadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <div style="text-align: center; margin: 0 auto;">
     <asp:TextBox ID="txtZipCode" ValidationGroup="Search" runat="server" MaxLength="5" Width="133px" Height="20px"></asp:TextBox>
      <telerik:RadButton runat="server" ID="btnSearch" Text="Search" ValidationGroup="Search">
       <Icon PrimaryIconCssClass="rbSearch" PrimaryIconLeft="4" PrimaryIconTop="4" />
      </telerik:RadButton>      
        <br /><br />
        <asp:Panel ID="pnlSearch" Height="100%" DefaultButton="btnSearch" Width="100%" runat="server">
            <asp:Literal ID="litTimeOfSearch" runat="server"></asp:Literal><br /><br /><br /><br />
        </asp:Panel>
    </div>
    </form>
</body>
</html>

After this you can use some event handling to perform the necessary action postback.

protected void Page_Load(object sender, EventArgs e)
 {
 
     this.btnSearch.Click += new EventHandler(btnSearch_Click);
 
 }
 
 void btnSearch_Click(object sender, EventArgs e)
 {
     Thread.Sleep(2000);
     litTimeOfSearch.Text = string.Format("<b>Last Search Executed at</b>: {0} <br/> <b>Zip code </b> : {1}",  DateTime.Now.ToShortTimeString()
         ,txtZipCode.Text);
 }
Iana Tsolova
Telerik team
 answered on 20 Jul 2011
2 answers
115 views
I have sql table like below.I want to show it in tree view


id   parentid     name
1     NULL       outlook
2     1      overcast
3     1       rainy
4     1       sunny
5     2        yes
6     3        wind
7     4      humidity
8     6       strong
9     6        weak
10    7        high
11    8         no
12    9         yes
13   10          no
14   15         yes
15   7        normal
please help me if any one knows.....
dhanya
Top achievements
Rank 1
 answered on 20 Jul 2011
0 answers
97 views
Hello,

I have a radgrid that i want to display images inside one of its columns

the XML file looks like this where home.jpg and home1.jpg are stored in a folder and they represent the name of the image
<?xml version="1.0" encoding="utf-8" ?>
<Files>
    <item ID="1">
        <filename>home.jpg</filename>
    </item>
  
  <item ID="2">
    <filename>home1.jpg</filename>
  </item>
  
</Files>

Thanks a lot for your help
Mike
Mike_T
Top achievements
Rank 1
 asked on 20 Jul 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?