Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
124 views
I'm adapting the load on demand from web service example. I'm adding an ID property and trying get the current/selected value (not the text!) from the combobox. It doesn't seem to be there.

I've pasted in the code so far. Could someone tell me what I'm doing wrong that the ID never shows up when calling get_value()?

using System.Collections;
using System.Collections.Generic;
using System.Web.Script.Services;
using System.Web.Services;
using Telerik.Web.UI;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class ComboBoxWebService : WebService
{
    [WebMethod]
    public IEnumerable GetItems(RadComboBoxContext context)
    {
        RadComboBoxData result = new RadComboBoxData();
        int numberOfItems = (int)(context["ItemsCount"] ?? 1000);
        List<ComboBoxItemData> items = new List<ComboBoxItemData>();
        for (int i = 0; i < numberOfItems; i++)
        {
            ComboBoxItemData itemData = new ComboBoxItemData();
            itemData.Text = "Item " + i;
            itemData.ID = i;
            items.Add(itemData);
        }
        return items;
    }
 
}
public class ComboBoxItemData
{
    private string text;
    private int id;
    public string Text
    {
        get { return text; }
        set { text = value; }
    }
    public int ID
    {
        get { return id; }
        set { id = value; }
    }
}




<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="DefaultCS" %>
 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
 
        <div>
            <label>Number of items to load:</label>
 
            <asp:ScriptManager runat="server"></asp:ScriptManager>
            <telerik:RadNumericTextBox runat="server" ID="ItemsCountTextBox" Width="60"
                Value="1000" MaxValue="4000" MinValue="100" ShowSpinButtons="True">
                <NumberFormat DecimalDigits="0" />
            </telerik:RadNumericTextBox>
            <telerik:RadComboBox runat="server" ID="RadComboBox1" Width="240" Height="200px"
                DataTextField="Text" DataValueField="id" OnClientItemsRequested="OnClientItemsRequested"
                OnClientItemsRequesting="OnClientItemsRequesting" AppendDataBoundItems="true"
                EnableLoadOnDemand="true" EnableItemCaching="true">
                <ExpandAnimation Type="none" />
                <CollapseAnimation Type="none" />
                <WebServiceSettings Path="ComboBoxWebService.asmx" Method="GetItems" />
            </telerik:RadComboBox>
            <telerik:RadScriptBlock runat="Server" ID="RadScriptBlock1">
                <script type="text/javascript">
                    var startTime;
                    var sendRequest = true;
                    var calculate = false;
 
                    function OnClientItemsRequesting(sender, args) {
                        var input = $find("<%= ItemsCountTextBox.ClientID %>");
                        args.get_context()["ItemsCount"] = input.get_value();
                        startTime = new Date();
                    }
                    function OnClientItemsRequested(sender, args) {
                        var endTime = new Date();
                        //         $get("total").innerHTML = endTime - startTime + "ms";
                    }
 
                    function OnClientDropDownClosed(sender, args) {
                        sender.clearItems();
                        if (args.get_domEvent().stopPropagation)
                            args.get_domEvent().stopPropagation();
                    }
 
                    function GetCurrentValue(sender, args) {
                        var combo = $find("<%= RadComboBox1.ClientID %>");
                       alert(combo.get_value());
              }
                </script>
            </telerik:RadScriptBlock>
            <telerik:RadButton ID="btnSelect" runat="server" Text="Select" OnClientClicked="GetCurrentValue">
            </telerik:RadButton>
        </div>
    </form>
</body>
</html>
Plamen
Telerik team
 answered on 11 Sep 2013
1 answer
62 views
protected void RadDataPager1_PageIndexChanged(object sender, RadDataPagerPageIndexChangeEventArgs e)
        {
            show();
        }
        protected void RadDataPager1_TotalRowCountRequest(object sender, RadDataPagerTotalRowCountRequestEventArgs e)
        {

            AllClass.SearchDef Def = new AllClass.SearchDef();
            Def.Business = this.RadBusi; Def.ProSeries = this.RadPro; Def.PtoTyp = this.RadPtoTyp;
            Def.Disposal = this.RadDisposal; Def.STimd = this.TxtSTim.Text; Def.OTimd = this.TxtOTim.Text;
            Def.ProCode = this.RadProCode;
            Def.OilWay = this.RadOilWay.Text;
            Def.STima = this.TxtSTim.Text;
            Def.OTima = this.TxtOTim.Text;       
            string sc = "select count(*) from tbAss where(1=1) " + AllClass.getwa(Def);
            int cnt = Convert.ToInt32(AllClass.ExecuteScalar(sc, con));
            e.TotalRowCount = cnt;
        }
        string GenerateButtonText(string argument)
        {
            return String.Format("<span>{0}</span>", int.Parse(argument) + 1);
        }

        protected void RadDataPager1_FieldCreated(object sender, RadDataPagerFieldCreatedEventArgs e)
        {
            if (e.Item.Field is RadDataPagerButtonField && (e.Item.Field as RadDataPagerButtonField).FieldType == PagerButtonFieldType.Numeric)
                foreach (IButtonControl ctrl in e.Item.Controls)
                    ctrl.Text = GenerateButtonText(ctrl.CommandArgument);
        }
sometimes the event"RadDataPager1_PageIndexChanged" doesn't work. and the event"RadDataPager1_TotalRowCountRequest
" happens every post.I think you guys really have to see the modes of "AspNetPager".

"
Daniel
Telerik team
 answered on 11 Sep 2013
2 answers
98 views
Hi

Let's say, we have many items in the rotator provided from database and each item should be shown for some time different other items in the rotator as en example:

item 1 for 1 min
item 2 for 39 second
item 3 for 2 mins

Do you think it's possible to work with control? do you advise on other method to achieve this.
BTW, the time for each item is stored in the database.

Many Thanks
Rami
Liesa
Top achievements
Rank 1
 answered on 11 Sep 2013
1 answer
286 views
Using the example from http://www.telerik.com/help/aspnet-ajax/listbox-client-templates.html, I was able to set up my ListBox using javascript to add items and attributes. When the item is added to my listbox, the text property is displayed but the other attributes are not.  When I view the rendered HTML, I can see that the attributes have been successfully added to my item. I would think that based on the ClientItemTemplate I have created, those values should show in the ListBox by the text, but they do not.

My end goal is to have the listbox display each attribute in table format.  Everything must be done clientside.  Any help is appreciated!

Rendered HTML:
< li class="rlbItem" id="selectMarketControl_RadListBox1_i0" Highlighted="False" StateCode="XY" City="Z" DataKey="123">
        <span class="rlbText">
                Text - Test Market

Javascript:
    //Get properties to add to the list box
    var nodeText = "Test Market";
    var dataKey = "123";
    var city = "Z";
    var stateCode = "XY";
    var highlighted = "False";
    //Create ListBox Item 
    var listbox = $find("<%= RadListBox1.ClientID %>");
    var item = new Telerik.Web.UI.RadListBoxItem();
    item.set_text(nodeText);
    item.set_value(dataKey);

//Set the list box item's custom attributes var attributes = item.get_attributes(); attributes.setAttribute("DataKey", dataKey); attributes.setAttribute("City", city); attributes.setAttribute("StateCode", stateCode); attributes.setAttribute("Highlighted", highlighted);
//Add item to the Listbox
listbox.trackChanges(); listbox.get_items().add(item); item.bindTemplate(); listbox.commitChanges();

ClientItemTemplate:

<
ClientItemTemplate> <table cellpadding="0" border="1" cellspacing="0" id="tblSelectedItems1"> <tr style="height: 18px;"> <td class="selectedMarketsGridColumnHospital"> #= Text # </td> <td class="selectedMarketsGridColumnCity"> #= Attributes.City # </td> <td class="selectedMarketsGridColumnState"> #= Attributes.StateCode # </td> <td style="text-align: center;" class="selectedMarketsGridColumnHighlighted"> <asp:CheckBox ID="Highlighted" runat="server" Checked=' #= Attributes.Highlighted #' ToolTip="Click to Highlight" Visible="true" /> </td> <td class="selectedMarketsGridColumnDelete"> <asp:ImageButton ID="btnRemove" AlternateText="Remove" Visible="true" Width="20px" runat="server" ImageUrl="../../Images/Buttons/btnGridRemove.gif" CommandName="Delete" CommandArgument='#= Attributes.DataKey #' ToolTip="Click to Remove" /> </td> </tr> </table> </ClientItemTemplate>
Rosemary
Top achievements
Rank 1
 answered on 11 Sep 2013
3 answers
551 views
I know that I'm missing something, but could someone give me simple example code for this?

So far I have this:

There are two textboxes, a button, and two listboxes on the page, currently I'm only concerned with RadListBox1.  I want to be able to add the values from the textboxes to labels (or text) in a template format in the listbox when the user clicks the button.  I want to be able to set the position and color of the text.  The value portion of the item will be an ID that doesn't need to be displayed.

Currently this all works if I don't use a template and I just concatenate the text from both textboxes.  But I don't know how to do this with a template.  I've put labels in the itemtemplate section below with text="#= Text #" but nothing displays in the listbox.  The item is added and it has the right text and value, but it's just a very narrow row with no text showing.

Relevant code below:

<script type="text/javascript">
            var listBox;

            function pageLoad() {
                listBox = $find("<%= RadListBox1.ClientID %>");
            }

            function addItem() {
                var itemText = $find("<%= RadTextBox1.ClientID %>").get_value();
                //Set a value also to mimic having an ID column in the control.
                var itemValue = 15
                if (!itemText) {
                    alert("Please specify the text for the new item.");
                    return false;
                }

                var itemText2 = $find("<%= RadTextBox2.ClientID %>").get_value();
                if (!itemText2) {
                    alert("Please specify text2 for the new item.");
                    return false;
                }

                var itemFullText = "" + itemText + " ;     Volume: " + itemText2

                listBox.trackChanges();
                //Instantiate a new client item
                var item = new Telerik.Web.UI.RadListBoxItem();
                item.set_text(itemFullText);
                item.set_value(itemValue);
                item.set_selected(true);
                item.bindTemplate();
                listBox.get_items().add(item);
                item.scrollIntoView();
                listBox.commitChanges();
                return false;
            }

        </script>

<telerik:RadTextBox ID="RadTextBox1" Runat="server">
        </telerik:RadTextBox>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <telerik:RadTextBox ID="RadTextBox2" Runat="server">
        </telerik:RadTextBox>
&nbsp;&nbsp;
        <telerik:RadButton ID="RadButton1" runat="server" AutoPostBack="False" 
            onclientclicked="addItem" Text="RadButton">
        </telerik:RadButton>
        <br />
        <br />
&nbsp;&nbsp;&nbsp;&nbsp;
        <telerik:RadListBox ID="RadListBox1" runat="server" AllowDelete="True" 
            AllowReorder="True" AllowTransfer="True" TransferToID="RadListBox2" Height="150px" Width="300px">
            <ItemTemplate>
        
    </ItemTemplate>

<ButtonSettings TransferButtons="All"></ButtonSettings>
        </telerik:RadListBox>
        <telerik:RadListBox ID="RadListBox2" runat="server"  Height="150px" Width="300px">
            <ButtonSettings TransferButtons="All">
            </ButtonSettings>
        </telerik:RadListBox>


Rosemary
Top achievements
Rank 1
 answered on 11 Sep 2013
1 answer
73 views
Hi. i have this scenario
In a multipage i have a radchart..i have a button to generate a pdf and send it by response.write..when i press the button..the events it's ok..the image of radchart are still visible in the selected view but when i change to other view the image is not..i have to do right click and show image to see it..why?
Petar Kirov
Telerik team
 answered on 11 Sep 2013
2 answers
286 views
Is it posible to assign 2 datakeys to grid?

DataKeyNames

 

 

="CheckovID" ????? and "groupID"

 

Jayesh Goyani
Top achievements
Rank 2
 answered on 11 Sep 2013
1 answer
123 views
I have the following code to save the attachments in a folder outside the DB.
Line 5 is giving me troubles during the creation of new records because the value to assign to "recordID" at the time of creation of a new record does not yet exist.



protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem edititem = (GridEditableItem)e.Item;
            GridEditableItem editedItem = e.Item as GridEditableItem;
                string recordID = editedItem.GetDataKeyValue("TransazioneID").ToString();
                string subPath = "Allegati\\" + recordID;
                bool isExists = System.IO.Directory.Exists(Server.MapPath(subPath));
                if (!isExists)
                    System.IO.Directory.CreateDirectory(Server.MapPath(subPath));
                RadUpload upload = (edititem.EditManager.GetColumnEditor("columnAllegati") as GridAttachmentColumnEditor).RadUploadControl;
                upload.TargetFolder = "Allegati\\" + recordID;
 
            }
        }
So my idea is to add a condition on top of this method that would execute it only if a new record is not being created. Something along those lines.....
How can I do something like that? 
Jayesh Goyani
Top achievements
Rank 2
 answered on 11 Sep 2013
2 answers
216 views
Hi all,

I would like to fire a javascript confirm popup when the user wants to change page (by setting a page number or by using previous / next page buttons).

Here is a quick description of the grid :

A user can update some input fields in a grid and a button below the grid lets the user save the values. I would like to prevent him from losing its updated data when he changes page by displaying a javascript confirm popup.

The confirm popup will ask if he really wants to change page and if it is the case, we lauch the postback and we change page. If not, the page change event is canceled and the user can save its values.


Thanks
TANSERI
Top achievements
Rank 1
 answered on 11 Sep 2013
6 answers
228 views
I have a hierarchical Telerik RadGrid that sometimes contains child entries that are empty. For these, I want to overwrite the default text "No child records to display" with something user locale specific.

So I can do this:

       
<telerik:RadGrid ID ="SettingsGrid" ... /><br>
            <mastertableview ... /><br>
                <DetailTables><br>
                    <telerik:GridTableView ... /><br>
                        <asp:Label ID="NoRecordLabel" runat="server" Text="whatever"/></div></NoRecordsTemplate>


Which causes the text "whatever" to appear when it should.

But I obviously want to do this dynamically, but I have failed in both of two ways:

1) By referencing my .resx file in the .ascx file. I import it's namespace and reference a certain resource as such:

    Text="<%$ Resx:SiteTextResources.Globals_Close %>"

(This works in other files in the same solution)

But this only produces empty text.

2) I haven't been successful at retrieving the Label programatically from the code behind. I looked at this: http://www.telerik.com/community/forums/aspnet-ajax/grid/how-to-access-controls-in-norecordstemplate.aspx but didn't get that approach to work, as I just can't seem to find the Label. I get an OutOfBoundsException, which I guess means the GetItems() method returns null.

Any ideas? Would appreciate it a lot!
C
Top achievements
Rank 1
 answered on 11 Sep 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?