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

Hi,

I'm sure this is something silly on my part, but I can't spot it.

The following code works:

var x = 'text';
var y = 'Red';
var selectedColorButtonValue = String(x + y);
var selectedColorButton = toolBar.findItemByValue(selectedColorButtonValue);

Now, since the actual value of y is dynamic and only known at run time, I have this code:

var selectedColorButtonValue = getColorButtonValue(fontColor); // Returns 'Red' for this demo
selectedColorButtonValue = String('text' + selectedColorButtonValue);
var selectedColorButton = toolBar.findItemByValue(selectedColorButtonValue);

The above does NOT work. The toolbarbutton that I'm trying to find is not found!

The toolbarbutton in question is one of several items in a RadToolBarSplitButton.

I have written to the console, and the value of selectedColorButtonValue appears fine.

Can anyone spot what I'm doing wrong.

Thanks

Jim

 

Hristo Valyavicharski
Telerik team
 answered on 17 Jun 2015
17 answers
1.2K+ views
Hello

I'm having problem passing parameters to user control used in edit mode of radgrid

I Have a RadGrid with some users data. I use a custom user control for FormTemplate.

The user control has it's own logic implemented to edit user data and takes one parameter "id_user". (It has public String id_user with get and set method defined  in codebehind)

I tried to pass this parameter to UserControl as seen in code below, but it doesnt work. when i pass this parameter to label it shows. User control also works fine if I pass static parameter (example:   id_user="2" ).

What is the right way to pass parameters to UC?

<EditFormSettings EditFormType="Template"
   <FormTemplate> 
       <asp:Label ID="Label4" runat="server" Text='<%# Bind("id") %>'></asp:Label> 
       <uc1:edit_user ID="edit_user1" runat="server" id_user='<%# Bind("id") %>' />    
   </FormTemplate> 
   <EditColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" 
               uniquename="EditCommandColumn"
    </EditColumn> 
</EditFormSettings>

I'm would also like to know how to pass parameters when attachig UserControls like this:
 <EditFormSettings EditFormType="WebUserControl" UserControlName="edit_user.ascx"

Thank you







Eyup
Telerik team
 answered on 17 Jun 2015
6 answers
1.2K+ views
If i use RadGrid in this way (http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/templateformupdate/defaultcs.aspx), and if inside that FormTemplateEditForm i have another RadGrid, how can i "find" it? If I use (RadGrid)this.Master.FindControl("RadGrid2") i get a null value.

How cand i acces some controls in TemplateEditForm? How can i "find" them?
Jayesh Goyani
Top achievements
Rank 2
 answered on 16 Jun 2015
3 answers
238 views
ASP.NET c# .NET Framework 4.0
Telerik ASP.NET AJAX v2014.2.724.40

I'm trying to style the MediaPlayer as a small mini player for playing only audio files.  I've figured out how to remove the HD button, Full Screen button, Title bar but am having trouble figure out how to remove the background image and also getting the volume control to position horizontally and just to the right of the volume button.

Any help is greatly appreciated.

Warren
Galin
Telerik team
 answered on 16 Jun 2015
9 answers
722 views

Hi Telerik Team, Hi All,

I have a problem with ajaxifying RadTooltTip.

My case is (drafts):

<RadAjaxPanel>

     <RadTooltip>

            <Button>

 

I want to make Button ajaxified. So clicking on in will not do postback, but do ajax request.

How can I do it? Please answer ASAP, It's very important to me.

Kin
Top achievements
Rank 1
 answered on 16 Jun 2015
3 answers
692 views

I have a dynamically generated grid where the first 4 rows are basically headers. "Project Name", "Customer Name", "division Name", "Sector Name"

For each project we have 2 columns. "Plan" and "Assign".

The 4 headers I listed should span the plan and assign columns. See the attached screen shot "Report Before Scrolling (everything looks good).png" to see what the desired output should be.

 I used this thread as a starting point on how to make text in one row span 2 columns for a dynamically generated grid:

http://www.telerik.com/support/code-library/span-cells-in-grid-over-multiple-positions

My guess is that the part where you try to track the previousIndex compared to the current index is where I have issues.

When the report is first rendered to the screen it looks correct. Once you use the horizontal scroll the colspan values for the columns start to change. To see the HTML example of this I've included 2 screen shots. One called "HTML Before Scrolling - Colspan values look correct.png" and one called "HTML after scrolling -Colspan values have changed.png". 

Here is the OnPreRender code where I set the colspan and very feebly attempt to manage the indeces of the items (read help!):

 

protected void radGrid1_OnPreRender(object sender, EventArgs e)
       {
           var headerRows = HeaderRows;
 
           if (headerRows == null) return;
 
           foreach (var row in headerRows)
           {
 
               var currentProjectID = row["projectID"].ToString();
 
               var currentPlanColumnName = "Plan" + "_" + currentProjectID;
               var currentAssignColumnName = "Assign" + "_" + currentProjectID;
 
               foreach (GridDataItem dataItem in radGrid1.MasterTableView.Items)
               {
                   dataItem[currentPlanColumnName].ColumnSpan = 2;
                   dataItem[currentAssignColumnName].Visible = false;
 
                   int previousItemIndex = dataItem.ItemIndex - 1;
                   if (previousItemIndex >= 0)
                   {
                       if (dataItem["Employees"].Text == dataItem.OwnerTableView.Items[previousItemIndex]["Employees"].Text)
                       {
                           dataItem.OwnerTableView.Items[previousItemIndex]["Employees"].RowSpan = 2;
                           dataItem["Employees"].Visible = false;
                       }
                   }
               }
           }
       }

 As I stated above the code in the OnPreRender where it compares the dataItem text to the previousItemIndex's text is where I'm probably causing the issue??

 Any help is greatly appreciated. 

Thank you :)​

 

                                   

Julian
Top achievements
Rank 1
 answered on 16 Jun 2015
1 answer
243 views

Hi Guys,

 I have a strange issue where the radcombobox allows the user to enter text and search data, also this data which he entered is allowed to save.

 

<telerik:radcombobox id="rdChangeOwner" skin="Web20" cssclass="RadComboBoxDropDownrcbScroll"
dropdowncssclass="RadComboBoxDropDownrcbScroll" runat="server" font-names="calibri"
font-size="11pt" width="230px" allowcustomtext="false" height="180px" enableloadondemand="True"
showmoreresultsbox="true" enablevirtualscrolling="true" emptymessage="Please Select..."
radcomboboximageposition="Right" zindex="10000002" onitemsrequested="ddlChangeOwnerItemsRequested"
causesvalidation="true" highlighttemplateditems="true" onclientblur="rdChangeOwnerBlur">
</telerik:radcombobox>

 

Initial Value of DropDown is "Asif Mohammed"

Looking for a Employee in picker and entered Asif


Didn’t not select the populated value(Asif Mohammed), just left the entered text as "Asif".

Asif is not there in the list, but "Asif Mohammed" is available, but it allowed me to save Asif into DB and hence got me error because internally it was not able to resolve.

 

Please help in getting a solution for this Issue.

Thanks and Regards,

Mohammed Asif Mtext

Nencho
Telerik team
 answered on 16 Jun 2015
10 answers
431 views
Thanks
An
Top achievements
Rank 1
 answered on 16 Jun 2015
1 answer
308 views

Hi,

I have a RadGrid on my web page in which I am implementing only "Add records" functionality.
When I try to click on "Add" button, nothing happens (it do not show panel to add records in it)

Please reply what mistake I am doing in my code.

Below is the .aspx (say "Default.aspx" page) code:

<telerik:RadMultiPage ID="RadMultiPage4" runat="server" SelectedIndex="0" Width="100%">
                                                                            <telerik:RadPageView ID="RadPageView3" runat="server" Width="100%">
                                                                                <telerik:RadAjaxPanel ID="RadAjaxPanel3" runat="server">
                                                                                            
                                                                                     <asp:label ID="Label2" runat="server" style="display: none;"/>
                                                                               
          <telerik:RadGrid ID="RGGSTChat" runat="server"  AutoGenerateColumns="false"
              ShowStatusBar="true" EnableEmbeddedSkins="true" Skin="Outlook"
              OnNeedDataSource= "rggstChat_NeedDataSource" OnInsertCommand="RGGSTChat_InsertCommand">
 
          <mastertableview commanditemdisplay="Top" autogeneratecolumns="false" datakeynames="ChatID"
            insertitempageindexaction="ShowItemOnCurrentPage" ShowFooter="True">
                    <CommandItemSettings AddNewRecordText="New" />
                                    <Columns>
                                         
                                        <telerik:GridBoundColumn DataField="ChatID" HeaderText="Id"
                                            UniqueName="ChatID" SortExpression="ChatID" Visible="false">
                                            <ItemStyle HorizontalAlign="Right" />
                                            <FooterStyle HorizontalAlign="Right" />
                                        </telerik:GridBoundColumn>
 
                                        <telerik:GridBoundColumn DataField="ChatTo" HeaderText="To"
                                            UniqueName="ChatTo" SortExpression="ChatTo">
                                            <ItemStyle HorizontalAlign="Right" />
                                            <FooterStyle HorizontalAlign="Right" />
                                        </telerik:GridBoundColumn>
 
                                        <telerik:GridBoundColumn DataField="ChatCc" HeaderText="Cc"
                                            UniqueName="ChatTo" SortExpression="ChatTo">
                                            <ItemStyle HorizontalAlign="Right" />
                                            <FooterStyle HorizontalAlign="Right" />
                                        </telerik:GridBoundColumn>
                                         
                                        <telerik:GridBoundColumn DataField="ChatSubject" HeaderText="Subject"
                                            UniqueName="ChatSubject" SortExpression="ChatSubject">
                                            <ItemStyle HorizontalAlign="Right" />
                                            <FooterStyle HorizontalAlign="Right" />
                                        </telerik:GridBoundColumn>
 
                                        <telerik:GridBoundColumn DataField="ChatContent" HeaderText="Content"
                                            UniqueName="ChatContent" SortExpression="ChatContent">
                                            <ItemStyle HorizontalAlign="Right" />
                                            <FooterStyle HorizontalAlign="Right" />
                                        </telerik:GridBoundColumn>                                     
                                         
                                    </Columns>
                                    <EditFormSettings>
                                        <EditColumn ButtonType="ImageButton" />
                                    </EditFormSettings>
                                    <PagerStyle AlwaysVisible="True" PageSizeControlType="RadComboBox" />
                   </mastertableview>
            </telerik:RadGrid>
 
 
                                                                                </telerik:RadAjaxPanel>
                                                                            </telerik:RadPageView>
                                                                        </telerik:RadMultiPage>

C# code:

protected void rggstChat_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        Label GUID = fvIPRForm.FindControl("TempGUID") as Label; // RequestID
        RadGrid RGGSTChat = fvIPRForm.FindControl("RGGSTChat") as RadGrid;
        if (!string.IsNullOrEmpty(Request.QueryString["RequestID"]))
        {
            GUID.Text = Request.QueryString["RequestID"];
        }
 
        if (string.IsNullOrEmpty(GUID.Text))
        {
            GUID.Text = Session["GUID"].ToString();
        }
 
        DataTable dt = IPRRequest.SelectChatData(new Guid(GUID.Text));
        RGGSTChat.DataSource = dt;
 
        Response.Write("Page_Load Error. Reason: " + GUID.Text);
    }

protected void RGGSTChat_InsertCommand(object sender, GridCommandEventArgs e)
    {
        GridEditableItem item = e.Item as GridEditableItem;
 
        Label requestID = fvIPRForm.FindControl("TempGUID") as Label;
 
        string chat_to = (item["lblTo"].Controls[1] as Label).Text;
        string chat_cc = (item["lblCc"].Controls[2] as Label).Text;
        string chat_subj = (item["lblSubject"].Controls[3] as Label).Text;
        string chat_Content = (item["lblContent"].Controls[4] as Label).Text;
        string loginUser = AD_Guard.Checker(Session["LoginUser"].ToString()) + "";
 
        IPRRequest.InsertChatData(new Guid(requestID.Text), chat_to, chat_cc, chat_subj, chat_Content, loginUser);  
    }

This is the .dll (say "abc.cs" page) code, this .dll is used for DB connection:

public static DataTable SelectChatData(Guid requestID)
        {
            Data data = new Data();
            Dictionary<string, object> input = new Dictionary<string, object>()
            {
                {"@RequestId", requestID}
                //{"@ChatID", null},
                //{"@ChatTo", chatTo},
                //{"@ChatCc", chatCC},
                //{"@ChatSubject", chatSubj},
                //{"@ChatContent", chatMsg}
            };
            DataTable dt = data.ExecuteQuery(CommandType.StoredProcedure, "Invoice.usp_tbl_Request_Chat_Select", input);           
            return dt;
        }
    
        public static DataTable InsertChatData(Guid requestID, string chat_to, string chat_cc, string chat_subj,
            string chat_Content, string loginUser)
        {
            Data data = new Data();
            Dictionary<string, object> input = new Dictionary<string, object>()
            {
                {"@RequestID", requestID},
                {"@ChatTo", chat_to},
                {"@ChatCc", chat_cc},
                {"@ChatSubject", chat_subj},
                {"@ChatContent", chat_Content},
                {"@CreatedBy", loginUser},
                {"@CreatedDate", DateTime.Now.ToString()}
                 
            };
            DataTable dt = data.ExecuteQuery(CommandType.StoredProcedure, "[Invoice].[usp_tbl_Request_Chat_Insert]", input);
            return dt;
        }

 

Konstantin Dikov
Telerik team
 answered on 16 Jun 2015
4 answers
165 views

Hi there,

 The RadcomboBox OnSelectedIndexChanged  event fired unexpected after I refresh page in firefox, however, it is working fine in IE and Chrome. Here is my code and scenario. Please help. Thank you very much.

1 Use firefox to open the page

2 Select value from the first ComboBox

3 Select value from the second ComboBox

4 Refresh Page

5 Click the "Explore" button on the page, the OnSelectedIndexChanged  event of the first RadComboBox got fired in Firefox (working fine in IE and Chrome).

 

Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadFormDecorator ID="FormDecorator1" runat="server"  />
    <div class="qsf-demo-canvas">
        <div class="continents">
            <telerik:RadComboBox ID="RadComboBox1" runat="server" Width="186px"
                AutoPostBack="true"  Filter="Contains" datatextfield="Name" datavaluefield="ID"
                OnDataBound="ddlBox1_DataBound" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
            </telerik:RadComboBox>
        </div>
        <div class="countries">
            <telerik:RadComboBox ID="RadComboBox2" runat="server" Width="186px"
                AutoPostBack="true"  Filter="Contains" datatextfield="Name" datavaluefield="ID"
                OnDataBound="ddlBox2_DataBound" OnSelectedIndexChanged="RadComboBox2_SelectedIndexChanged">
            </telerik:RadComboBox>
        </div>
        <div>
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" CellSpacing="0" AllowSorting="true"
            GridLines="None" Width="800px">
            <ClientSettings>
                <Selecting AllowRowSelect="true" />
            </ClientSettings>
            <MasterTableView AutoGenerateColumns="False" DataKeyNames="ID">
                <Columns>
                   
                    <telerik:GridBoundColumn DataField="ID" DataType="System.String"
                        HeaderText="StateID" ReadOnly="True" SortExpression="ID" UniqueName="ID">
                    </telerik:GridBoundColumn>
                    <telerik:GridDateTimeColumn DataField="Name" DataType="System.String"
                       HeaderText="Name" SortExpression="Name" UniqueName="Name">
                    </telerik:GridDateTimeColumn>
                </Columns>
            </MasterTableView>
            <FilterMenu EnableImageSprites="False">
            </FilterMenu>
        </telerik:RadGrid>
            </div>
        <p class="buttons">
            <asp:Button ID="Button1" runat="server" Text="Explore" OnClick="Button1_Click" />
        </p>
        <div class="result">
            <asp:Label runat="server" ID="Literal1" />
        </div>
    </div>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadComboBox1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadComboBox2" />
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadComboBox2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    </form>
</body>
</html>
 

Code behind file:

 

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Security;
using System.Collections.Generic;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
 
public partial class Default : System.Web.UI.Page
{
    public class State
    {
        public String ID { get; set; }
        public String Name { get; set; }     
    }
 
    public class City
    {
        public String ID { get; set; }
        public String Name { get; set; }
        public String StateID { get; set; }
    }
 
    public List<State> GetStateList()
    {
        List<State> _list = new List<State>();
 
        State d1 = new State();
        d1.Name = "AB";
        d1.ID = "1";
 
        State d2 = new State();
        d2.Name = "BC";
        d2.ID = "2";
 
        State d3 = new State();
        d3.Name = "ON";
        d3.ID = "3";
 
        _list.Add(d1);
        _list.Add(d2);
        _list.Add(d3);
 
        return _list;
    }
 
    public List<City> GetCityList(String _stateID)
    {
        List<City> _list = new List<City>();
        List<City> _newList = new List<City>();
 
        City c1 = new City();
        c1.Name = "Calgary";
        c1.ID = "1";
        c1.StateID = "1";
 
        City c2 = new City();
        c2.Name = "Edmonton";
        c2.ID = "2";
        c2.StateID = "1";
 
        City c3 = new City();
        c3.Name = "Vancouver";
        c3.ID = "3";
        c3.StateID = "2";
 
        City c4 = new City();
        c4.Name = "Victoria";
        c4.ID = "4";
        c4.StateID = "2";
 
        City c5 = new City();
        c5.Name = "Toronto";
        c5.ID = "5";
        c5.StateID = "3";
 
 
        City c6 = new City();
        c6.Name = "Ottawa";
        c6.ID = "6";
        c6.StateID = "3";
 
        _list.Add(c1);
        _list.Add(c2);
        _list.Add(c3);
        _list.Add(c4);
        _list.Add(c5);
        _list.Add(c6);
 
        var _result = _list.Where(t => t.StateID == _stateID);
 
        foreach (var _item in _result)
        {
            City d = new City();
            d.ID = _item.ID;
            d.StateID = _item.StateID;
            d.Name = _item.Name;
            _newList.Add(d);
        }
 
        return _newList;
    }
 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
            LoadBox1();
    }
 
    protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        if (e.Value != String.Empty)
        {
            LoadBox2(e.Value);
            List<State> _test = new List<State>();
            RadGrid1.DataSource = _test;
            RadGrid1.DataBind();
        }
    }
 
    protected void RadComboBox2_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        if (e.Value != String.Empty)
        {
            LoadGrid();
        }
    }
 
    public void LoadGrid()
    {
        RadGrid1.DataSource = GetStateList();
        RadGrid1.DataBind();
    }
 
    protected void LoadBox1()
    {
        RadComboBox1.DataSource = GetStateList();
        RadComboBox1.DataBind();
    }
 
    protected void LoadBox2(string _stateID)
    {
        RadComboBox2.DataSource = GetCityList(_stateID);
        RadComboBox2.DataBind();
    }
 
    protected void ddlBox1_DataBound(object sender, EventArgs e)
    {
        var combo = (RadComboBox)sender;
        combo.Items.Insert(0, new RadComboBoxItem("Please Select", String.Empty));
 
        RadComboBox2.Items.Insert(0, new RadComboBoxItem("Please Select", String.Empty));
    }
 
    protected void ddlBox2_DataBound(object sender, EventArgs e)
    {
        var combo = (RadComboBox)sender;
        combo.Items.Insert(0, new RadComboBoxItem("Please Select", String.Empty));
    }
 
    protected void Button1_Click(object sender, EventArgs e)
    {
        //Literal1.Text = string.Empty;
    }
}

 


 

Ivan Danchev
Telerik team
 answered on 16 Jun 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?