Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
81 views
Why the width of grid is beeing changed during insert?
See attachments pls... This is in IE only...
Rosen
Telerik team
 answered on 05 May 2010
2 answers
129 views
I have a grid that uses a LinqDataSource. The LinqDataSource uses the event Selecting to fill out the data retrieved. All works fine except that even though I am using a RadAjaxManager the grid still "blinks" when I use the paging controls instead of how the 300,000 row Telerik demo works. Will I not be able to accomplish that with the way I am doing it? My Linq query is a join. I have attached the code I use. If anyone has any tips, please let me know. I like the way the demo handles the postbacks.
using System;  
using System.Collections;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using System.Data;  
using System.Data.Sql;  
using System.Data.SqlClient;  
using System.Diagnostics;  
using System.Transactions;  
using Infragistics.WebUI.UltraWebGrid;  
using Infragistics.WebUI.UltraWebNavigator;  
using Infragistics.WebUI.WebDataInput;  
using Telerik.Web.UI;  
 
namespace CharityCheck  
{  
    public partial class Registrations : CharityCheck.MyPage  
    {  
        int m_nType = -1;  
        String m_strMemberStatus = "";  
 
        protected void Page_Load(object sender, EventArgs e)  
        {  
            Master.Menu.MenuItemClicked += new MenuItemClickedEventHandler(Menu_MenuItemClicked);  
 
            m_strMemberStatus = Session["Registrations:MemberStatus"].ToString();  
            m_nType = Convert.ToInt32(Session["Registrations:Type"]);  
            Master.Heading = String.Format("{0} ({1})",   
                                        Session["Registrations:Heading"].ToString(),  
                                        m_strMemberStatus);  
 
            if (!IsPostBack || Session["MenuSelected"] != null)  
            {  
                if (Session["Registrations:SearchBy"] != null)  
                {  
                    WebTextEdit1.Text = Session["Registrations:SearchBy"].ToString();  
                    checkBoxExact.Checked = Convert.ToBoolean(Session["Registrations:Exact"]);  
                    RadComboBoxSearchBy.SelectedValue = Session["Registrations:Search"].ToString();  
                    RadGrid1.DataSourceID = Session["Registrations:DataSourceID"].ToString();  
                    RadGrid1.DataBind();  
                }  
                Session["MenuSelected"] = null;  
                Session["Registrations:SearchBy"] = null;  
                Session["Registrations:Exact"] = null;  
                Session["Registrations:Search"] = null;  
                Session["Registrations:DataSourceID"] = null;  
            }  
        }  
 
        void Menu_MenuItemClicked(object sender, WebMenuItemEventArgs e)  
        {  
            if (e.Item.Text == "Back")  
            {  
                Session["Programmatic"] = true;  
                Response.Redirect("/Admin/AdminDefault.aspx");  
            }  
        }  
 
        protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)  
        {  
            if (e.Item is GridDataItem)  
            {  
                GridDataItem dataItem = e.Item as GridDataItem;  
                dataItem.Selected = true;  
                int nID = Convert.ToInt32(dataItem["ID"].Text);  
                CellClick(e.CommandName, nID, e);  
            }  
        }  
 
        protected void CellClick(string strName, int nID, Telerik.Web.UI.GridCommandEventArgs e)  
        {  
            switch (strName)  
            {  
                case "Profile":  
                    Session["Registrations:SearchBy"] = WebTextEdit1.Text.Trim();  
                    Session["Registrations:Exact"] = checkBoxExact.Checked;  
                    Session["Registrations:DataSourceID"] = RadGrid1.DataSourceID;  
                    Session["Registrations:Search"] = RadComboBoxSearchBy.SelectedValue;  
                    switch (m_nType)  
                    {  
                        case 0:     // Charities  
                        case 1:     // Professional Fundraisers  
                            Session["Programmatic"] = true;  
                            Session["ProfessionalFundraiserGeneralInfo:CompanyID"] = nID;  
                            Session["ProfessionalFundraiserGeneralInfo:Type"] = Utility.GetType(m_nType);  
                            Response.Redirect("~/Admin/ProfessionalFundraiserGeneralInfo.aspx");  
                            //RedirectSavingPageState("~/Admin/ProfessionalFundraiserGeneralInfo.aspx");  
                            break;  
                        case 2:     // Casino Operators  
                            Session["Programmatic"] = true;  
                            Session["CasinoGeneralInfo:CompanyID"] = nID;  
                            Response.Redirect("~/Admin/CasinoGeneralInfo.aspx");  
                            //RedirectSavingPageState("~/Admin/CasinoGeneralInfo.aspx");  
                            break;  
                        case 3:     // Lottery Operators  
                            Session["Programmatic"] = true;  
                            Session["LotteryGeneralInfo:CompanyID"] = nID;  
                            Response.Redirect("~/Admin/LotteryGeneralInfo.aspx");  
                            //RedirectSavingPageState("~/Admin/LotteryGeneralInfo.aspx");  
                            break;  
                        case 4:     // Awareness Publishers  
                            Session["Programmatic"] = true;  
                            Session["PublishersGeneralInfo:CompanyID"] = nID;  
                            Response.Redirect("~/Admin/PublishersGeneralInfo.aspx");  
                            //RedirectSavingPageState("~/Admin/PublishersGeneralInfo.aspx");  
                            break;  
                        case 5:     // Telemarketers  
                            Session["Programmatic"] = true;  
                            Session["TelemarketingGeneralInfo:CompanyID"] = nID;  
                            Response.Redirect("~/Admin/TelemarketingGeneralInfo.aspx");  
                            //RedirectSavingPageState("~/Admin/TelemarketingGeneralInfo.aspx");  
                            break;  
                        case 6:     // Business  
                            Session["Programmatic"] = true;  
                            Session["BusinessGeneralInfo:CompanyID"] = nID;  
                            Response.Redirect("~/Admin/BusinessGeneralInfo.aspx");  
                            //RedirectSavingPageState("~/Admin/BusinessGeneralInfo.aspx");  
                            break;  
                        case 7:     // Residential  
                            Session["Programmatic"] = true;  
                            Session["ResidentialGeneralInfo:CompanyID"] = nID;  
                            Response.Redirect("~/Admin/ResidentialGeneralInfo.aspx");  
                            //RedirectSavingPageState("~/Admin/ResidentialGeneralInfo.aspx");  
                            break;  
                    }  
                    break;  
                case "Report":  
                    break;  
            }  
        }  
 
        protected void RadGrid1_DeleteCommand(object source, GridCommandEventArgs e)  
        {  
            GridDataItem dataItem = e.Item as GridDataItem;  
            dataItem.Selected = true;  
            int nID = Convert.ToInt32(dataItem.GetDataKeyValue("ID"));  
 
            using (TransactionScope scope = new TransactionScope())  
            {  
                using (CharityCheckEntities context = new CharityCheckEntities())  
                {  
                    FundraisingActivity.DeleteByCompanyID(nID, context);  
                    PublisherFundraiserActivity.DeleteByCompanyID(nID, context);  
                    TelemarketingBusinessActivity.DeleteByCompanyID(nID, context);  
                    CasinoFundraisingActivity.DeleteByCompanyID(nID, context);  
                    LotteryFundraisingActivity.DeleteByCompanyID(nID, context);  
                    IncomeStatement.DeleteByCompanyID(nID, context);  
                    BalanceSheet.DeleteByCompanyID(nID, context);  
                    StatementOfCashFlow.DeleteByCompanyID(nID, context);  
                    SolicitantNotes.DeleteByCompanyID(nID, context);  
                    BusinessRecommendations.DeleteByCompanyID(nID, context);  
                    JobPostings.DeleteByCompanyID(nID, context);  
                    Files.DeleteByCompanyID(nID, context);  
                    RequestedReports.DeleteByCompanyID(nID, context);  
                    SponsoredCharitableReports.DeleteByCompanyID(nID, context);  
                    Company.DeleteByID(nID, context);  
                    context.SaveChanges();  
 
                    scope.Complete();  
                }  
            }  
        }  
 
        protected void LinqDataSource1_Selecting(object sender, LinqDataSourceSelectEventArgs e)  
        {  
            String strSearch = WebTextEdit1.Text.Trim();  
            String strType = Utility.GetType(m_nType);  
 
            CharityCheckEntities entities = new CharityCheckEntities();  
            var data = from company in entities.CompanySet  
                       from user in entities.UserSet  
                       where company.ID == user.CompanyID &&  
                             company.MemberStatus == m_strMemberStatus &&  
                             company.Type == strType &&  
                            ((RadComboBoxSearchBy.SelectedValue == null || RadComboBoxSearchBy.SelectedValue == "Name")  
                               ? ((strSearch.Length != 0)  
                                    ? checkBoxExact.Checked  
                                        ? company.CompanyName == strSearch  
                                        : company.CompanyName.StartsWith(strSearch)  
                                    : true)  
                               : ((strSearch.Length != 0)  
                                    ? checkBoxExact.Checked  
                                        ? user.MemberID == strSearch  
                                        : user.MemberID.StartsWith(strSearch)  
                                    : true))  
                        orderby company.CompanyName  
                        select new 
                        {  
                            company.ID,  
                            company.CompanyName,  
                            RegistrationDate=company.RegistrationDate,  
                            user.Phone,  
                            user.FullName,  
                            company.Type,  
                        };  
            e.Result = data;  
            e.Arguments.TotalRowCount = data.Count();  
        }  
    }  
}  
 
<%@ Page Title="" Language="C#" MasterPageFile="~/NestedMasterPage2.master" AutoEventWireup="true" CodeBehind="Registrations.aspx.cs" Inherits="CharityCheck.Registrations" %> 
<%@ MasterType virtualpath="~/NestedMasterPage2.master" %> 
<%@ Register tagprefix="igtxt" namespace="Infragistics.WebUI.WebDataInput" Assembly="Infragistics35.WebUI.WebDataInput.v10.1, Version=10.1.20101.1011, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" %> 
<%@ Register tagprefix="igcmbo" namespace="Infragistics.WebUI.WebCombo" Assembly="Infragistics35.WebUI.WebCombo.v10.1, Version=10.1.20101.1011, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" %> 
<%@ Register tagprefix="ig" namespace="Infragistics.Web.UI.ListControls" Assembly="Infragistics35.Web.v10.1, Version=10.1.20101.1011, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" %> 
<%@ Register tagprefix="iglist" namespace="Infragistics.Web.UI.ListControls" Assembly="Infragistics35.Web.v10.1, Version=10.1.20101.1011, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" %> 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">  
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
        <script type="text/javascript" id="igClientScript1">  
            var RadGrid1;  
 
            function GetGridObject(sender, eventArgs) {  
                RadGrid1 = sender;  
            }  
            function webImageButtonSearch_Click(oButton, oEvent) {  
                RadGrid1.get_masterTableView().rebind();  
            }  
        </script> 
    </telerik:RadCodeBlock> 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" > 
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="webImageButtonSearch">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="webImageButtonSearch" /> 
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="RadGrid1">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" /> 
    <table> 
        <tr> 
            <td valign="middle">  
                <asp:Label ID="Label1" runat="server" Text="Search By:" CssClass="aLabel"></asp:Label> 
            </td> 
            <td valign="middle">  
                <telerik:RadComboBox ID="RadComboBoxSearchBy" runat="server" width="90px" 
                    MarkFirstMatch="True"   
                    Skin="Vista" TabIndex="1" CausesValidation="False"   
                    ToolTip="Choose how to search, either by Name or by Member ID." > 
                    <Items> 
                        <telerik:RadComboBoxItem runat="server" Text="Name" Value="Name" /> 
                        <telerik:RadComboBoxItem runat="server" Text="Member ID" Value="Member ID" /> 
                    </Items> 
                </telerik:RadComboBox> 
            </td> 
            <td valign="middle">  
                <igtxt:WebTextEdit ID="WebTextEdit1" runat="server" Width="360px" TabIndex="2" ToolTip="Enter the criteria to search by.">  
                </igtxt:WebTextEdit> 
            </td> 
            <td> 
                <igtxt:WebImageButton ID="webImageButtonSearch" runat="server"   
                    ImageDirectory="~/Images"    
                    Text="Search" CausesValidation="False" TabIndex="3"   
                    ToolTip="Click this button to start the search." AutoSubmit="False" > 
                    <ClientSideEvents Click="webImageButtonSearch_Click" /> 
                    <Appearance> 
                        <Image Url="../Images/Search-16x16.png" /> 
                    </Appearance> 
                </igtxt:WebImageButton> 
            </td> 
            <td> 
                <asp:CheckBox ID="checkBoxExact" runat="server" Text="Exact"   
                    TextAlign="Left" CssClass="aCheckBox" TabIndex="4" ToolTip="Checking this will cause the search to find the information exactly the way it was typed. Otherwise, the search will find anything that contains the criteria." /> 
            </td> 
        </tr> 
    </table> 
    <telerik:RadGrid ID="RadGrid1" runat="server" allowpaging="True"   
        datasourceid="LinqDataSource1" gridlines="None" showfooter="True"   
        onitemcommand="RadGrid1_ItemCommand"    
        allowautomaticdeletes="True" autogeneratecolumns="False" 
        ondeletecommand="RadGrid1_DeleteCommand"   
        skin="Office2007" > 
        <MasterTableView tablelayout="Fixed" datasourceid="LinqDataSource1" > 
            <Columns> 
                <telerik:GridBoundColumn DataField="CompanyName" DefaultInsertValue=""   
                    HeaderText="Company Name" SortExpression="CompanyName"   
                    UniqueName="CompanyName">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="FullName" DefaultInsertValue=""   
                    HeaderText="Contact Name" SortExpression="FullName"   
                    UniqueName="FullName">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Phone" DefaultInsertValue="" 
                    HeaderText="Phone" SortExpression="Phone"   
                    UniqueName="Phone">  
                </telerik:GridBoundColumn> 
                <telerik:GridDateTimeColumn DataField="RegistrationDate" DefaultInsertValue="" 
                    HeaderText="Registration Date" ReadOnly="True" SortExpression="RegistrationDate"   
                    DataFormatString="{0:d}" 
                    UniqueName="RegistrationDate" > 
                    <HeaderStyle Width="105px" /> 
                </telerik:GridDateTimeColumn> 
                <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Profile"   
                    ImageUrl="~/Images/Profile-16x16.png" Text="Go to the General Information Page" UniqueName="Profile">  
                    <HeaderStyle Width="20px" /> 
                    <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" /> 
                </telerik:GridButtonColumn> 
                <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Reports"   
                    ImageUrl="~/Images/Reports-16x16.png" Text="Reports" UniqueName="Reports">  
                    <HeaderStyle Width="20px" /> 
                    <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" /> 
                </telerik:GridButtonColumn> 
                <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete"   
                    ImageUrl="~/Images/Delete-16x16.png" Text="Delete this company" UniqueName="Delete" 
                    ConfirmText="Delete this company?" ConfirmDialogType="RadWindow"   
                    ConfirmTitle="Delete">  
                    <HeaderStyle Width="20px" /> 
                    <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" /> 
                </telerik:GridButtonColumn> 
                <telerik:GridBoundColumn DataField="ID" DefaultInsertValue="" Visible="false" 
                    HeaderText="ID" SortExpression="ID" UniqueName="ID"   
                    DataType="System.Int32" ReadOnly="True">  
                </telerik:GridBoundColumn> 
            </Columns> 
        </MasterTableView> 
        <ClientSettings>    
            <Selecting AllowRowSelect="true" />    
            <ClientEvents OnGridCreated="GetGridObject"></ClientEvents> 
        </ClientSettings>    
        <PagerStyle Position="TopAndBottom" /> 
    </telerik:RadGrid> 
 
    <asp:LinqDataSource ID="LinqDataSource1" runat="server"   
        AutoPage="False" ContextTypeName="CharityCheck.CharityCheckEntities"   
        onselecting="LinqDataSource1_Selecting"   
        TableName="CompanySet">  
    </asp:LinqDataSource> 
</asp:Content> 
 
Tsvetoslav
Telerik team
 answered on 05 May 2010
1 answer
91 views
Hello,

I Have a problen related to "telerik:GridDropDownColumn" ,
i have two GridDropDownlist in telerik radgrid when i going edit mode
 i want to call first GridDropDown selectindexchange event and get selected value and pass to second GridDropDown

SqlDataSource as a difault value.
Plz anyone Help me...

Princy
Top achievements
Rank 2
 answered on 05 May 2010
2 answers
155 views
Hi All,

I am using 2009 q2 of Telerik. 
I have a grid with client select column and I want to show an alert on uncheck of client select checkbox.
I captured the event deselecing for the checkbox and shown alert.

But the problem is when I do DeSelect All from header check box, I am getting alert for all the rows. I need an event for DeSelectAll so that I can set a flag and do not show alert for all rows, and show only one alert.

Which event I can use for DeSelect All?

Thanks.
Jimmy.
Jimmy Vithalani
Top achievements
Rank 1
 answered on 05 May 2010
3 answers
114 views
Hi Experts,

We have a Grid that we bind using the Simple Object collection.
The Format of the Object is such that:
ParentObject
            ChildObjectCollection
                        ChildObjectProperty

Hence when we bind our grid we provide the collection of ParentObject to it.
We have a GridBoundColumn there with following settings:
    .UniqueName = "MyColumn"

    .DataField =

"ChildObject(0).sFullName"  or "ChildObject.(0).sFullName" 

 

    .DataType =

GetType(String)

This work perfectly fine and we are able to see the data as required.
But the issue is that when we are  trying to filter on this column its not responding at all and seems like its not able to find the column itself.Hence the grid is still intact with same number of rows.
We have also set the EnableLinqExpressions = false, hence filtering operation is more close to SQL version.
I also tried setting the FilterExpression manually before the NeedDataSource Event and check that expression is still there.But still same result.
Please let me know if you have ideas.
Thanks for  your help in advance

Regards,
Aayam Singh

 

Tsvetoslav
Telerik team
 answered on 05 May 2010
1 answer
74 views
Hi
I'm having trouble getting the right data in my radgrid. I am working with an asp.net webapplication with C# and a WCF webservice. This webservice returns me a list of values which I have to put in class so I can show them in my radgrid. The problem is that the radgrid gets the wrong attributes. Can somebody take a look at this code and tell me what I'm doing wrong? Here's my code:

codebehind (c#):
foreach (string key in keys) { 
if (lijst.TryGetValue(key, out value)) { 
        properties.Add(new VO_ObjectPropertyHelper(key,value[0],value[1])); 
      } 
} 
 
rgProperties.DataSource = properties; 
rgProperties.MasterTableView.DataSource = properties; 
 

VO_ObjectHelper class:
public partial class VO_ObjectPropertyHelper { 
        public string propID { get; set; } 
        public string name { get; set; } 
        public string value { get; set; } 
 
        public VO_ObjectPropertyHelper(string _propID, string _name, string _value) { 
            this.propID = _propID; 
            this.name = _name; 
            this.value = _value; 
        } 
    } 


webpage:
<telerik:RadGrid ID="rgProperties" runat="server" AutoGenerateColumns="False" GridLines="None" AllowSorting="True" ShowHeader="false" Skin="Vista"> 
    <mastertableview> 
        <RowIndicatorColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
        </RowIndicatorColumn> 
        <ExpandCollapseColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
        </ExpandCollapseColumn> 
        <Columns> 
            <telerik:GridBoundColumn DataField="name" HeaderText="Meter Eigenschappen" SortExpression="name" UniqueName="name" >                
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="value" HeaderText="" SortExpression="value" UniqueName="value"> 
            </telerik:GridBoundColumn> 
        </Columns> 
    </mastertableview> 
</telerik:RadGrid> 
 
Ronald Kamp
Top achievements
Rank 1
 answered on 05 May 2010
1 answer
132 views

The following UserControl, OpportunityList.ascx, using the Ajaxed RadGrid refreshes the whole page the first time in when you click the Next button in the paging navigation bar.  Subsequently, it works properly refereshing only the control itself.  Is there a fix for this?


[By the way we bind the data to the radGrid in the UserControl's Page_PreRender event, otherwise we get the error 
Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.   If there is a better way to work around this error, please let us know.]

_______________________________________________________________________________________
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="OpportunityList.ascx.cs" Inherits="Deloitte.Ca.OnePortal.UserControls.OpportunityList, Deloitte.Ca.OnePortal.UserControls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=97bcd997dcc9fbb7" %>
<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.WebControls" TagPrefix="asp" %>
<%@ Register Assembly="Telerik.Web.UI, Version=2010.1.415.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Label ID="lblError" runat="server"></asp:Label>
<telerik:RadAjaxManager ID="radAjaxManager" runat="server">
  <AjaxSettings>
    <telerik:AjaxSetting AjaxControlID="rgdOpportunityList">
      <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="rgdOpportunityList" LoadingPanelID="radAjaxLoadingPanel" />
      </UpdatedControls>
    </telerik:AjaxSetting>
  </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="radAjaxLoadingPanel" runat="server" Skin="Default">
</telerik:RadAjaxLoadingPanel>

<telerik:RadGrid ID="rgdOpportunityList" runat="server" Width="100%"
AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" PageSize="3"
GridLines="None" Skin="Windows7">
  <MasterTableView OverrideDataSourceControlSorting="true">
    <RowIndicatorColumn>
      <HeaderStyle Width="20px"></HeaderStyle>
    </RowIndicatorColumn>
    <ExpandCollapseColumn>
      <HeaderStyle Width="20px"></HeaderStyle>
    </ExpandCollapseColumn>
  </MasterTableView>
</telerik:RadGrid>

Pavlina
Telerik team
 answered on 05 May 2010
9 answers
854 views

Hi,
I have checkboxes in rad combobox.
My first checkbox has the value All.
What I want is, I would like to select checkboxes for all when 'All' is selected,and if any one checkbox is deselected, then the check of 'All' should be deselected.

Below is the aspx code of rad combobox.
I want to achieve this through javascript.

<

radC:RadComboBox runat="server" ID="RadComboBox1" AllowCustomText="True" HighlightTemplatedItems="True"

 

 

Skin="WebBlue" SkinsPath="~/RadControls/ComboBox/Skins" UseEmbeddedScripts="False"

 

 

OnClientDropDownOpening="OnClientDropDownOpening" OnClientDropDownClosing="OnClientDropDownClosing"

 

 

OnClientSelectedIndexChanging="onSelectedIndexChanging" OnClientBlur="OnClientBlur"

 

 

DropDownWidth="140px" Height="110px" Width="120px">

 

 

<ItemTemplate>

 

 

<asp:CheckBox runat="server" ID="chk" onclick="checkboxClick();" Text='<%# DataBinder.Eval(Container, "Text") %>' />

 

 

</ItemTemplate>

 

 

<Items>

 

 

<radC:RadComboBoxItem Text="All" Value="0" ID="chbSelectAll" onclick="javascript:SelectAll();" runat="server" />

 

 

<radC:RadComboBoxItem Text="Unassigned" Value="1" runat="server" />

 

 

<radC:RadComboBoxItem Text="Assigned" Value="2" runat="server" />

 

 

<radC:RadComboBoxItem Text="Reassigned" Value="4" runat="server" />

 

 

<radC:RadComboBoxItem Text="Posted" Value="5" runat="server" />

 

 

</Items>

 

 

</radC:RadComboBox>

Moderators/Admin please help.

 

Manish
Top achievements
Rank 1
 answered on 05 May 2010
1 answer
118 views
I use the PanelBar for navigation to other pages, which triggers a postback - thereby resetting the state of the PanelBar. I would like the PanelBar to persist the collapse/expand state of its items regardless of postbacks. I have tried the various fixes such as setting the PreventCollapse property on Items, trapping expand events client-side, etc but been unsuccessful in retaining state. It appears the only way to persist state is to write some sort of custom state handler that uses a hidden input field? Any advice would be appreciated.

Thanks!
Justin

btw: I am using the PanelBar in Sharepoint.
Nikolay Tsenkov
Telerik team
 answered on 05 May 2010
1 answer
107 views
Hi,

I'm attempting to use related Combo box's here is my code
var cboUsers; 
        var chkNewUser; 
        function pageLoad() { 
            cboUsers = $telerik.findComboBox('<%= Page.FindControlRecursive("cboUsers").ClientID %>'); 
            chkNewUser = $telerik.$('#<%= Page.FindControlRecursive("chkNewUser").ClientID %>'); 
        } 
 
        function cboUser_Load(sender) { 
            debugger; 
            var cboCompany = $telerik.findComboBox('<%= Page.FindControlRecursive("cboCompanies").ClientID %>'); 
            var cboUser = $telerik.toComboBox(sender); 
            var selectedValue = cboCompany.get_value(); 
            cboUser.set_text("Loading..."); 
            cboUser.clearSelection(); 
 
            if (selectedValue != "") { 
                cboUser.requestItems(selectedValue, false); 
                 
            } 
        } 
 
        function cboUser_IndexChanged(sender, args) { 
            debugger; 
            var item = args.get_item(); 
             
            var cnHidVal = $telerik.$('#'+'<%= Page.FindControlRecursive("selectedUser").ClientID %>'); 
 
            cnHidVal.val(item.get_value()); 
 
        } 
 
        function LoadUsers(combo, eventArgs) { 
            var cboCompany = $telerik.toComboBox(combo); 
            var item = eventArgs.get_item(); 
            cboUsers = $telerik.findComboBox('<%= Page.FindControlRecursive("cboUsers").ClientID %>'); 
            cboUsers.set_text("Loading..."); 
            cboUsers.clearSelection(); 
            if (item.get_index() != -1) { 
                cboUsers.requestItems(item.get_value(), false); 
            } 
        } 
 
        function companyDropDownClosed(sender, args) { 
            var cboCompanybox = $telerik.toComboBox(sender); 
 
            var selectIndex = cboCompanybox.get_selectedIndex(); 
            cboUsers = $telerik.findComboBox('<%= Page.FindControlRecursive("cboUsers").ClientID %>'); 
 
            if (selectIndex == -1) { 
                cboUsers.clearSelection(); 
                cboUsers.clearItems(); 
            } 
 
        } 
 
        function cboUserItemsRequest(sender, args) { 
            var userCbo = $telerik.toComboBox(sender); 
            userCbo.trackChanges(); 
 
            if (userCbo.get_items().get_count() == 0) { 
                chkNewUser.trigger('click'); 
                userCbo.disable(); 
                userCbo.commitChanges(); 
                return; 
            } 
            else { 
 
                userCbo.enable(); 
                var comboItem = new Telerik.Web.UI.RadComboBoxItem(); 
                comboItem.set_text(""); 
                comboItem.set_value(""); 
                var items = userCbo.get_items() 
                items.insert(0, comboItem); 
                userCbo.commitChanges(); 
                if (chkNewUser.attr("checked")) 
                    chkNewUser.trigger('click'); 
            } 
 
        var cnHidVal = $telerik.$('#' + '<%= Page.FindControlRecursive("selectedUser").ClientID %>'); 
        if (cnHidVal.val() != "") { 
            for (i = 0; i < userCbo.get_items().get_count(); i++) { 
                var item = userCbo.get_items().getItem(i); 
                if (item.get_value() == cnHidVal.val()) { 
                    item.select(); 
                } 
 
            } 
        } 
Then on the server side i have an Custom Validator which does the following
protected void cboUsers_Validate(object sender, ServerValidateEventArgs args) 
        {  
            var newUserchecked = (System.Web.UI.WebControls.CheckBox)Page.FindControlRecursive("chkNewUser"); 
            RadComboBox cboUsers = (RadComboBox)Page.FindControlRecursive("cboUsers"); 
            args.IsValid = (newUserchecked.Checked) || (cboUsers.SelectedValue != "-1" && !newUserchecked.Checked); 
        } 
HTML Code here
<telerik:RadComboBox runat="server" OnClientLoad="cboUser_Load" OnClientItemsRequested="cboUserItemsRequest" OnClientSelectedIndexChanged="cboUser_IndexChanged" 
                                                        OnItemsRequested="cboUsers_ItemsRequested" Width="100%" ID="cboUsers" /> 
                                                    <asp:CustomValidator OnServerValidate="cboUsers_Validate" ErrorMessage="Please Select a User" ControlToValidate="cboUsers" 
                                                        EnableClientScript="false" Display="None" runat="server" /> 
BUT on the server side code SelectedValue is "" i have got a work around which is to put the selected value into a hidden input field but i shouldn't have too.


Kalina
Telerik team
 answered on 05 May 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?