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

I have two RadListBox. Data in first box is populated from database using RadListBoxItem and I have set an attribute for each item. In the second box, I've created custom context menu. After I adding the item from first box to second box, user can select some option using the context menu. On context menu selection, I need to get the Attribute I set before and update the attribute value according to the context menu selection so I can used it for later process.Currently, I unable to even the attributes I set previously using the context menu's javascript. Please guide how to read ListItem's attribute and update the attribute to a new value.

 

This is how I add the item to the first box with attribute.

this._sortingList = new List<Sorting>();
this._sortingList = DBConnection.getSortingList();
 
foreach (var s in this._sortingList)
 {
        RadListBoxItem item = new RadListBoxItem();
        item.Text = s.Description;
        item.Value = s.Id.ToString();
        item.Attributes["myorder"] = "0";
        this.RadListBox1.Items.Add(item);
}

 

Thus custom context menu javascript.

    function showContextMenu(sender, e) {
    var menu = $find("<%= cm1.ClientID %>");
    var rawEvent = e.get_domEvent().rawEvent; menu.show(rawEvent);
    e.get_item().select();
    $telerik.cancelRawEvent(rawEvent);
 
}
function onItemClicked(sender, e) {
    var listBox = $find("<%= RadListBox1.ClientID %>");
    var listItem = listBox.get_selectedItem();
    var menuItem = e.get_item();
    if (menuItem.get_text() == "Ascending"){
        alert(listItem.get_attributes().getAttribute("myorder"));
    }
    else if (menuItem.get_text() == "Descending") {
        alert(listItem.get_attributes().getAttribute("myorder"));
    }
}
Gangatharan
Top achievements
Rank 1
 answered on 21 Mar 2018
0 answers
128 views

I have two RadListBox. Data in first box is populated from database using RadListBoxItem and I have set an attribute for each item. In the second box, I've enabled custom context menu. After I adding the item from first box to second box, user can select some option using the context menu. On context menu selection, I need to get the Attribute I set before and update the attribute value according to the context menu selection so I can used it for later process.Currently, I unable to even the attributes I set previously using the context menu's javascript. Please guide how to read ListItem's attribute and update the attribute to a new value.

 

This is how I add the item to the first box with attribute.

this._sortingList = new List<Sorting>();
this._sortingList = DBConnection.getSortingList();
  
foreach (var s in this._sortingList)
 {
        RadListBoxItem item = new RadListBoxItem();
        item.Text = s.Description;
        item.Value = s.Id.ToString();
        item.Attributes["myorder"] = "0";
        this.RadListBox1.Items.Add(item);
}

 

This is custom context menu javascript.

function showContextMenu(sender, e) {
    var menu = $find("<%= cm1.ClientID %>");
    var rawEvent = e.get_domEvent().rawEvent; menu.show(rawEvent);
    e.get_item().select();
    $telerik.cancelRawEvent(rawEvent);
  
}
function onItemClicked(sender, e) {
    var listBox = $find("<%= RadListBox1.ClientID %>");
    var listItem = listBox.get_selectedItem();
    var menuItem = e.get_item();
    if (menuItem.get_text() == "Ascending"){
        alert(listItem.get_attributes().getAttribute("myorder"));
    }
    else if (menuItem.get_text() == "Descending") {
        alert(listItem.get_attributes().getAttribute("myorder"));
    }
}
Gangatharan
Top achievements
Rank 1
 asked on 21 Mar 2018
2 answers
300 views

Hi,

Sorry if this has been asked elsewhere, I cannot find any answers on this topic..

I am using a media player in a dockzone control which works great.  The only issue I have is the player, which is set to autoplay, shows the titlebar and play controls automatically on start and only disappears when the user hovers over the control and then off it.  I would like the player ONLY to show the controls when the user hovers over it (ie do not show it until they want to control the video).

Thanks!

Eyup
Telerik team
 answered on 21 Mar 2018
4 answers
207 views
I have tasks in my current implementation that run to 6pm but the timeline only shows 8am to 4pm. How do I go about adjusting the Gantt to show 7am to 6pm?
Kasim
Top achievements
Rank 2
 answered on 21 Mar 2018
6 answers
526 views
I have a RadGrid with EditMode="Batch".  It has a template column.  In this column (in the EditItemTemplate) is a RadComboBox with CheckBoxes="True".  

<telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" GridLines="None"
    AllowMultiRowEdit="True"
    AutoGenerateColumns="False" AllowAutomaticInserts="False" AllowAutomaticUpdates="False"
    OnNeedDataSource="GridNeedDataSource"
    OnPreRender="GridPreRender">
    <MasterTableView AllowSorting="True" EditMode="Batch">
        <Columns>
            <telerik:GridBoundColumn DataField="Id" HeaderText="Id" UniqueName="IdColumn" Display="False" ReadOnly="True">
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn HeaderText="Test Values" UniqueName="TestValuesColumn" ItemStyle-Width="400px">
                <EditItemTemplate>
                    <telerik:RadComboBox runat="server" ID="TestValuesComboBox" DropDownAutoWidth="Enabled"
                        HighlightTemplatedItems="True" CheckBoxes="True" EnableCheckAllItemsCheckBox="True">
                    </telerik:RadComboBox>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
        <BatchEditingSettings OpenEditingEvent="DblClick" />
    </MasterTableView>
</telerik:RadGrid>

protected void GridPreRender(object sender, EventArgs e)
{
    RadGrid grid = sender as RadGrid;
    if (grid != null)
    {
        GridTableView masterTable = grid.MasterTableView;
 
        var editor = masterTable.GetBatchEditorContainer("TestValuesColumn");
        var comboBox = (RadComboBox)editor.FindControl("TestValuesComboBox");
        comboBox.Items.Clear();
 
        for (int i = 1; i <= 10; i++)
        {
            RadComboBoxItem item = new RadComboBoxItem();
            item.Text = i.ToString();
            item.Value = i.ToString();
 
            comboBox.Items.Add(item);
            item.DataBind();
        }
    }
}

What I need to do is pre-check the values that have been previously saved.  I realize that there is really only "one" editor for the entire column, so I was wondering if there was some javascript (handling the BatchEditOpening maybe?) that could run through a comma separated list contained in a hidden field or something, and check the appropriate values when opening the cell for editing?  I set the contents of the RadComboBox in the grid's PreRender event, so it's only done once.

Perhaps another option is to have the RadComboBox set with EnableLoadOnDemand="true" and handle the OnItemsRequested to reload and select the data, after it handles the OnClientDropDownOpening="ClearComboBox" with the following code:

function ClearComboBox(sender, args) {
    if (sender.get_items().get_count() == 0) {
        return;
    }
    else {
        sender.clearItems();
        sender.requestItems("parameter", true);
    }
}

The trouble with option #2 is that I'm not sure how to get any values for that particular row to set up in code-behind.  So I don't know how to get the data from the database for that record.  Also, this will make a call to the database every time they open the ComboBox.

Any thoughts?


Eyup
Telerik team
 answered on 20 Mar 2018
0 answers
139 views

I have the following html:

<sq8:GridTemplateColumn DataField="FieldToFillChoiceValue" FilterImageToolTip="" HeaderText="" SortExpression="FieldToFillChoiceValue" UniqueName="FieldToFillValue" FilterControlAltText="">
    <EditItemTemplate>
        <sq8:TextBox runat="server" ID="tbFieldToFill" ValidationGroup="DecisionGroup" />
        <sq:BindableControl runat="server" TargetControlID="tbFieldToFill" DataField="FieldToFillTextValue"></sq:BindableControl>
        <asp:CustomValidator runat="server" ErrorMessage="CustomValidator" ID="cvFieldToFill" ValidationGroup="DecisionGroup"></asp:CustomValidator>
        <sq8:ComboBox runat="server" ID="cmbFieldToFill" ValidationGroup="DecisionGroup">
            <Localization NoMatches="" ShowMoreFormatString="" AllItemsCheckedString="" ItemsCheckedString="" CheckAllString="" MoreItemsWithoutTotalRowCount="" NoMoreItemsWithoutTotalRowCount=""></Localization>
        </sq8:ComboBox>
        <sq:BindableControl runat="server" TargetControlID="cmbFieldToFill" DataField="FieldToFillChoiceValue" />
    </EditItemTemplate>
    <ItemTemplate>
        <asp:Literal runat="server" ID="FieldToFillChoiceValue" Mode="Encode" />
        <sq:BindableControl runat="server" TargetControlID="FieldToFillChoiceValue" DataField="FieldToFillChoiceValue" />
        <asp:HiddenField runat="server" ID="hfFieldType" />
        <sq:BindableControl runat="server" TargetControlID="hfFieldType" DataField="FieldToFillType"></sq:BindableControl>
    </ItemTemplate>
</sq8:GridTemplateColumn>

 

And I'm signed to OnBatchEditOpening and OnBatchEditOpened events.

My problem is that when I get to the OnBatchEditOpened handler, the value of tbFieldToFill is "TextBox" (which is the value of the hidden field) without me setting or binding any value to the control.

In the OnBatchEditOpening handler, the text box still haven't been rendered.

How and why does the value get into the textbox control?

Thanks for any help.

Evgeny
Top achievements
Rank 1
 asked on 20 Mar 2018
0 answers
234 views

Hello,

I have 3 web parts each of which raise a different client side event to which the other 2 web parts react. Two of the web parts are asp .NET (Telerik) while the third is strictly client side JavaScript and REST services.

My issue is that the 2 asp .net web parts each perform a post back when they react to the event, passing some data to the server. Only one of the asp .net web parts processes their post back correctly. If the other ASP .NET web part is removed, everything works correctly.

I have considered serializing the post backs, so that one does not occur until the first has completed and rendered back to the client.

Is there a better way? Also my post backs are not showing the loading panel which does appear normally.

My client side event listener and post back code looks like this:

document.addEventListener('ADSBarcodeEvent', function (evt) {
    var barcode = evt.detail[0];
    var assetType = evt.detail[1];
    __doPostBack("<%=HiddenSearchRadButton.UniqueID%>", barcode + "||" + assetType);
}, false);

and on the server:

protected void HiddenSearchRadButton_Click(object sender, EventArgs e)
 {
     ProcessingExternalEvent = true; // stop infinite loop of events
 
     string passedArgument = Request.Params.Get("__EVENTARGUMENT");
     // barcode + "||" + assetType
     if (passedArgument.Contains("||"))
     {
         string[] delimiter = new string[] { "||" };
         string[] arguments = passedArgument.Split(delimiter, StringSplitOptions.None);
         string barcode = arguments[0];
         string assetType = arguments[1];
Marcel
Top achievements
Rank 1
 asked on 19 Mar 2018
1 answer
112 views

Dears,

 

I am new to RadGrid. I've a grid displayed without the Add New Record button. 

 

I dont understand that. I am using NeedDataSource event to bind the data

 

Regards,

 

Endashaw

Rumen
Telerik team
 answered on 19 Mar 2018
4 answers
486 views
I can't make the radpagelayout control has 100% width and height in big resolution (1920x1080). Do you can help me?
Flemming
Top achievements
Rank 1
Veteran
 answered on 17 Mar 2018
1 answer
378 views

 

The code is posted below. When I click on the selection list I want the id of the selection list item to appear in the query string of browser after a partial postback. Is this possible?

 

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="telerik.aspx.cs" Inherits="Webtest.telerik" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>     <title></title>     <script>         function getQueryStringValue(key) {             return decodeURIComponent(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + encodeURIComponent(key).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));         }         function addIdtoQueryString(itemId) {             var querystring = getQueryStringValue("filter");                          if(querystring=="")             {                 querystring = itemId;             }             else             {                 querystring = querystring + "+" + itemId;             }             return querystring;         }         function deleteIdFromQueryString(itemId) {             var querystring = getQueryStringValue("filter");             var ids = querystring.split("+");             var newQuerystring = "";             for (var i = 0; i < ids.length; i++) {                 console.log(ids[i]);             }             var indexOfItemToDelete = ids.indexOf(itemId);             ids.splice(indexOfItemToDelete, 1);             for (var i = 0; i < ids.length; i++) {                 if (i != 0) {                     newQuerystring += "+";                 }                 newQuerystring += ids[i];             }             return newQuerystring;         }         function itemClicked(list, args) {             var querystring ="";             if (args.get_item().get_checked() == true)             {                 querystring = addIdtoQueryString(args.get_item().get_value());             }             else             {                 querystring = deleteIdFromQueryString(args.get_item().get_value());             }             if (querystring != "")                 document.forms["form1"].action = "?filter=" + querystring;             else                 document.forms["form1"].action = "?";             alert(document.forms["form1"].action);         }     </script></head><body>     <form id="form1" runat="server">                         <telerik:RadScriptManager ID="rsManager" runat="server" AsyncPostBackTimeout="7200" />                 <telerik:RadAjaxManager ID="raManager" runat="server" EnableAJAX="true" />             <telerik:RadAjaxManagerProxy ID="rampCommodity" runat="server" >         <ajaxsettings>                <telerik:AjaxSetting AjaxControlID="paCommodity">                 <UpdatedControls>                     <telerik:AjaxUpdatedControl ControlID="paCommodity"></telerik:AjaxUpdatedControl>                 </UpdatedControls>             </telerik:AjaxSetting>         </ajaxsettings>     </telerik:RadAjaxManagerProxy>             <asp:Panel ID="paCommodity" runat="server">     <div>          <telerik:RadCheckBoxList runat="server" ID="Questionnaire" AutoPostBack="true"  CssClass="content" OnSelectedIndexChanged="Questionnaire_SelectedIndexChanged">              <ClientEvents OnItemClicked="itemClicked">              </ClientEvents>              <Items>                 <telerik:ButtonListItem Text="Game apps (puzzles, charades, etc.)" Value="0"  />                 <telerik:ButtonListItem Text="Sports apps (sports schedules, scores, headlines, etc.)" Value="1" />                 <telerik:ButtonListItem Text="Travel apps (airplane tickets, tourist guides, transportation info, etc.)" Value="2" />                 <telerik:ButtonListItem Text="News apps (news, national headlines, technology announcements, etc.)" Value="3" />                 <telerik:ButtonListItem Text="Entertainment apps (puzzles, charades, etc.)" Value="4" />                 <telerik:ButtonListItem Text="Social networking apps (location check-ins, friend status updates, etc.)" Value="5" />                 <telerik:ButtonListItem Text="Weather apps (local forecasts, natural disaster updates, etc.)" Value="6" />                 <telerik:ButtonListItem Text="Other" Value="7" />             </Items>         </telerik:RadCheckBoxList>              </div>                 </asp:Panel>          </form></body></html>

Attila Antal
Telerik team
 answered on 16 Mar 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?