Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
679 views

I have a radgrid and I can loo through the selected items.  If I set the for loop

for (int i = 0; i < totalSelected; i++)
     GridDataItem selectedItem = (GridDataItem) RadGrid1.SelectedItems[i]

it will loop in the order that they were selected and not the order of display on the screen.  Is there a way to loop through the selected based on the order in the grid?

for the time being I have found

foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
{
   if (item.Selected)
   {

but this will loop through the whole grid which seems kind of a waist when I should be able to just loop through the selected items.

Viktor Tachev
Telerik team
 answered on 10 Jan 2014
1 answer
68 views

I have a page that has a RadGrid with a Context Menu on it.   I am using the context menu to fire open a RadWindow that is hosting another aspx page with a RadProgressArea completing a long running process.   Once the job is finished I have some JS in a placeholder that I make visable to Rebind the radgrid and then close the RadWindow.


Everything works fine except if I rebind the RadGrid the RadWindow reopens back up.   What am I doing wrong?



Here is the main aspx page - stripped down to be simple.



<%@ Control Language="VB" AutoEventWireup="false" CodeFile="PartInventory.ascx.vb" Inherits="UserControls_PartInventory" %>
<telerik:RadCodeBlock runat="server" ID="RadCodeBlock2">
 
        <script type="text/javascript">
            
            function RowContextMenu(sender, eventArgs) {
                  
                var menu = $find("<%=RadMenu1.ClientID %>");
                var evt = eventArgs.get_domEvent();
 
                if (evt.target.tagName == "INPUT" || evt.target.tagName == "A") {
                    return;
                }
                var index = eventArgs.get_itemIndexHierarchical();
                document.getElementById("radGridClickedRowIndex").value = index;
 
                sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(), true);
                menu.show(evt);
                evt.cancelBubble = true;
                evt.returnValue = false;
 
                if (evt.stopPropagation) {
                    evt.stopPropagation();
                    evt.preventDefault();
                 
                }
            }
 
            function refreshGrid() {
                var masterTable = $find("<%=rgInventoryEdit.ClientID%>").get_masterTableView();
                masterTable.rebind();
            }
 
 
        </script>
 
    </telerik:RadCodeBlock>
<telerik:RadGrid ID="rgInventoryEdit" runat="server" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" CellSpacing="0" DataSourceID="sqlInventory" GridLines="None" Skin="WebBlue"
     AllowMultiRowSelection="true"  AllowAutomaticDeletes="True" >
    <ClientSettings>
            <ClientEvents OnRowContextMenu="RowContextMenu" />
            <Selecting CellSelectionMode="None" AllowRowSelect="True"></Selecting>
            <Resizing AllowColumnResize="True" AllowResizeToFit="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="True"></Resizing>
        </ClientSettings>
    <MasterTableView AutoGenerateColumns="False" DataKeyNames="InventoryID" DataSourceID="sqlInventory"  PageSize="25" ShowFooter="True" ShowHeader="true"  CommandItemDisplay="Top">
         <CommandItemTemplate>
                <div style="padding: 5px 5px;">
                      <asp:LinkButton ID="LinkButton1" runat="server" OnClick="SaveGridSettings" CommandName="SaveSettings"><img style="border:0px;vertical-align:middle;"  alt="" src="../../Images/Icons/24x24/save24x24.png"/> Save Layout</asp:LinkButton>   
                </div>
            </CommandItemTemplate>
        <Columns>
            <telerik:GridTemplateColumn HeaderText="Img"  AllowFiltering="False"  UniqueName="HasImages">
                <HeaderStyle Width="35px"></HeaderStyle>
                <ItemStyle Width="35px"></ItemStyle>
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink1" runat="server" Text="Link" Target="_blank" Visible='<%# Eval("HasImages")%>' ImageUrl="~/Images/BlueIcons/16x16/blue16_032.gif" onclick="window.open (this.href, 'child', 'height=800,width=800,scrollbars'); return false"
                        NavigateUrl='<%# String.Format("~/CarAndPartPics.aspx?NoMaster=True&InventoryNumber={0}&StockNumber={1}", Convert.ToString(Eval("InventoryNumber")), Convert.ToString(Eval("StockTicketNumber")))%>' />
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                    <ItemStyle CssClass="MyImageButton" />
                </telerik:GridEditCommandColumn>
            
             <telerik:GridButtonColumn ConfirmText="Delete this Part?" ConfirmDialogType="RadWindow"
                    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                    UniqueName="DeleteColumn">
                    <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                </telerik:GridButtonColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
<telerik:RadPersistenceManagerProxy ID="RadPersistenceManagerProxy1" runat="server">
        <PersistenceSettings>
            <telerik:PersistenceSetting ControlID="rgInventoryEdit" />
        </PersistenceSettings>
</telerik:RadPersistenceManagerProxy>
<input type="hidden" id="radGridClickedRowIndex" name="radGridClickedRowIndex" />
<telerik:RadContextMenu ID="RadMenu1" runat="server" OnItemClick="RadMenu1_ItemClick" SkinID="WebBlue"
        EnableRoundedCorners="true" EnableShadows="true">
        <Items>
            <telerik:RadMenuItem Text="Increase Prices">
            </telerik:RadMenuItem>
            <telerik:RadMenuItem Text="Do Multiple Operations">
            </telerik:RadMenuItem>
 
        </Items>
 
    </telerik:RadContextMenu>
<telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false" ReloadOnShow="true" runat="server" EnableShadow="true">
    <Windows>
        <telerik:RadWindow ID="rwOne" runat="server" ReloadOnShow="true" ShowContentDuringLoad="false" Behaviors="Close,Move"
                Modal="true" >
            </telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>
<asp:SqlDataSource ID="sqlInventory" runat="server" ConnectionString="<%$ ConnectionStrings: %>"
   
</asp:SqlDataSource>




Here is the code Behind.

Imports Telerik.Web.UI
 
 
Partial Class UserControls_PartInventory
    Inherits System.Web.UI.UserControl
 
    Protected Sub UserControls_PartInventory_Load(sender As Object, e As EventArgs) Handles Me.Load
 
        If Not IsPostBack Then
            LoadTelerikPF()
        End If
    End Sub
 
    
 
    Public Function SaveTelerikPF() As Boolean
        Try
            Dim mstr As MasterPage = Me.Parent.Page.Master
            Dim rp As Telerik.Web.UI.RadPersistenceManager = mstr.FindControl("RadPersistenceManager1")
            rp.SaveState()
        Catch ex As Exception
            Return False
        End Try
        Return True
    End Function
 
    Public Function LoadTelerikPF() As Boolean
        Try
            Dim mstr As MasterPage = Me.Parent.Page.Master
            Dim rp As Telerik.Web.UI.RadPersistenceManager = mstr.FindControl("RadPersistenceManager1")
            rp.LoadState()
        Catch ex As Exception
            Return False
        End Try
        Return True
    End Function
 
    Protected Sub SaveGridSettings(sender As Object, e As EventArgs)
        SaveTelerikPF()
    End Sub
 
    Protected Sub RadMenu1_ItemClick(sender As Object, e As Telerik.Web.UI.RadMenuEventArgs) Handles RadMenu1.ItemClick
 
        Dim intArray(rgInventoryEdit.SelectedItems.Count - 1) As Integer
        Dim intCount As Integer = 0
 
        For Each row As GridItem In rgInventoryEdit.SelectedItems
            intArray(intCount) = rgInventoryEdit.MasterTableView.Items(row.ItemIndex).GetDataKeyValue("InventoryID")
            intCount += 1
        Next
 
        Dim strGUID As String = Guid.NewGuid.ToString
        Session(strGUID) = intArray
 
        Select Case e.Item.Text
 
 
            Case "Increase Prices"
                RadWindowManager1.Windows(0).Title = "Increase Prices"
                RadWindowManager1.Windows(0).Height = 300
                RadWindowManager1.Windows(0).Width = 600
                RadWindowManager1.Windows(0).Left = 150
                RadWindowManager1.Windows(0).NavigateUrl = "~/UserControls/PartEditDialogs/IncreasePrice.aspx?sesKey=" + Server.HtmlEncode(strGUID)
                RadWindowManager1.Windows(0).VisibleOnPageLoad = True          
 
            Case "Do Multiple Operations"
 
        End Select
 
    End Sub
End Class




Here is the aspx page that opens up in the Radwindow.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="IncreasePrice.aspx.vb" Inherits="UserControls_PartEditDialogs_IncreasePrice" Theme="SkinFile" StylesheetTheme="SkinFile" %>
<style type="text/css">
    .auto-style1 {
        width: 348px;
    }
</style>
<telerik:RadCodeBlock runat="server" ID="RadCodeBlock2">
 
        <script type="text/javascript">
function GetRadWindow()  
    {  
       var oWindow = null;  
       if (window.radWindow) oWindow = window.radWindow;  
       else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;  
       return oWindow;  
    }  
</script>
 
    </telerik:RadCodeBlock>
 
<!DOCTYPE html>
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
            AsyncPostBackTimeout="3600"/>
 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        </telerik:RadAjaxManager>
        <telerik:RadProgressManager ID="RadProgressManager1" Runat="server" />
         
         
        <div>
 
            <table>
                <tr>
                    <td style="text-align: right">
                        <asp:Label ID="Label1" runat="server" SkinID="stdLabel" Text="Amount to add to Retail :"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="tbRetail" runat="server" Width="50px">0</asp:TextBox>
                    </td>
                    <td class="auto-style1">
                        <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="tbRetail" ErrorMessage="Please enter an amount between 0 and 1000" MaximumValue="1000" MinimumValue=".01"></asp:RangeValidator>
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        <asp:Label ID="Label2" runat="server" SkinID="stdLabel" Text="Amount to add to Wholesale :"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="tbWholesale" runat="server" Width="50px">0</asp:TextBox>
                    </td>
                    <td class="auto-style1">
                        <asp:RangeValidator ID="RangeValidator2" runat="server" ControlToValidate="tbWholesale" ErrorMessage="Please enter an amount between 0 and 1000" MaximumValue="1000" MinimumValue=".01"></asp:RangeValidator>
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        <asp:Button ID="btnSetPrices" runat="server" Text="Adjust Prices" />
                    </td>
                    <td> </td>
                    <td class="auto-style1"> </td>
                </tr>
            </table>
 
        </div>
 
        <asp:PlaceHolder ID="phCloseWindow" runat="server">
            <script>
                var oWin = GetRadWindow();
                var parentWindow = oWin.BrowserWindow;
                oWin.close();
                parentWindow.refreshGrid();
                
            </script>
        </asp:PlaceHolder>
 
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Width="600px" Height="300px" Runat="server" IsSticky="True" MinDisplayTime="1000" Skin="Default">
        </telerik:RadAjaxLoadingPanel>
        <div style="position:absolute;z-index:1000;top:10px;left:10px">
             <telerik:RadProgressArea ID="RadProgressArea1" runat="server" Skin="WebBlue" HeaderText="Current Progress" ProgressIndicators="FilesCountBar, CurrentFileName, TimeElapsed">
                   <Localization Uploaded="Uploaded" CurrentFileName="" UploadedFiles=""></Localization>
                </telerik:RadProgressArea>
        </div>
         
         
         
    </form>
</body>
</html>


Here is the code behind.

Imports Telerik.Web.UI
Imports System.Threading
 
Partial Class UserControls_PartEditDialogs_IncreasePrice
    Inherits System.Web.UI.Page
 
    Protected Sub UserControls_PartEditDialogs_IncreasePrice_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Not IsPostBack Then
            phCloseWindow.Visible = False
        End If
 
    End Sub
 
    Protected Sub btnSetPrices_Click(sender As Object, e As EventArgs) Handles btnSetPrices.Click
        Dim sesKey As String = Request.QueryString("sesKey")
        Dim invArray As Integer() = Session(sesKey)
        Dim bolSuccess As Boolean = True
        Dim strWarning As String = ""
 
        For Each intID As Integer In invArray
            Label1.Text += intID.ToString + vbCrLf
        Next
 
        Dim progress As RadProgressContext = RadProgressContext.Current
        progress.Speed = "N/A"
        progress.CurrentOperationText = "Part 1 of " + invArray.Count.ToString
        RadProgressArea1.Localization.CurrentFileName = "Re-Pricing Parts : "
        progress.OperationComplete = False
 
        Dim intProgress As Integer = 0
 
        For Each intInventoryID As Integer In invArray
            Thread.Sleep(1000)
            intProgress += 1
            progress.TimeEstimated = (invArray.Count - intProgress) * 100
            progress.CurrentOperationText = "Part " + intProgress.ToString() + " of " + invArray.Count.ToString
        Next
 
        phCloseWindow.Visible = bolSuccess
        progress.OperationComplete = True
 
    End Sub
End Class


Marin Bratanov
Telerik team
 answered on 10 Jan 2014
1 answer
223 views
I have a toolbar that has a SQL datasource.  During the page load event, I want to iterate through the buttons to make each of them a toggle button and I use the code below.  I don't seem to understand the object model.  How do I iterate through the buttons?

If Not IsPostBack Then
    For Each button As RadToolBarButton In radtoolMonths.Items
        button.AllowSelfUnCheck = True
        button.CheckOnClick = True
        button.PostBack = True
    Next
 
End If
Brian
Top achievements
Rank 2
 answered on 10 Jan 2014
1 answer
226 views
Hi All,

i have a rad list view.. i need to set allowscroll on that control.. how can i achieve this...

Regards,

Prassin
Shinu
Top achievements
Rank 2
 answered on 10 Jan 2014
3 answers
416 views
Hi All,

I was wondering if anyone has cracked RadGrid's to provide infinite scroll functionality.  To be more specific, I would like my RadGrids to behave like LinkedIn or FACEBOOK, where when you scroll down, rows are added to the bottom of the table as you scroll, with no other user interaction.

In my mind, I see firing a client-side event when the browser "hits" the bottom of the page, then running some javascript to run the next rows in order (similar to paging).  However, I don't have any great ideas on getting started.

Jim
Princy
Top achievements
Rank 2
 answered on 10 Jan 2014
3 answers
372 views
Please how can ii use  upload(Async) to select images onto a form and then save it into a database for later retrieval.
Any help or idea. 
Thanks in advance
Shinu
Top achievements
Rank 2
 answered on 10 Jan 2014
1 answer
155 views

hi,

I have created a UserControl to display the data using RadListView. I am loading this user Control dynamically in a webpage.



List is displayed properly and all the data is shown correctly. When user clicks on the edit link, it is able to go into edit mode. But when user clicks on the update button, it doesn't fire the Item Command event handler. It just closes the edit view and nothing is saved. When the control is loaded dynamically, should I have to register the event handlers again? In my case the Edit item template is a custom layout and button is inside the layout. Can you help to solve this issue?



<EditItemTemplate>
           <table cellspacing="0" cellpadding="0" style="width100%" border="0">
               <tr>
                   <td colspan="2" align="right">
                       <asp:LinkButton ID="UpdatePropertiesButton" runat="server" Text="Update" CommandName="Update" ></asp:LinkButton>
                       &nbsp;&nbsp;&nbsp;<asp:LinkButton ID="BtnCancel" runat="server" Text="Cancel" CommandName="Cancel" CausesValidation="False"></asp:LinkButton>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
               </tr>
</table>
</EditItemTemplate>








Marin
Telerik team
 answered on 10 Jan 2014
1 answer
80 views
I know this is a reoccurring question, but I need to ask it again. Is there any more thought about providing color syntax highlighting in the RadEditor's HTML view?
Misho
Telerik team
 answered on 10 Jan 2014
1 answer
178 views
Hi,
      I have try to setup my AjaxUpdated Control as below code:  
      And got the error  as attached image but it's running OK if i just click "continuous".
      Any idea what's the problem is ? Thanks 

      <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest" DefaultLoadingPanelID="LoadingPanel1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID ="MRibbonBar" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="MRibbonBar">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID ="MasterGrid" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>

Radoslav
Telerik team
 answered on 10 Jan 2014
3 answers
63 views
This issue only appears to occur with touch devices. I tested on iPad and Nexus 7.

When clicking on the dropdown area to select an item, any controls under the selected dropdown area will also be clicked.

For example, if  a RadButton happens to be under a dropdown item and you click on the dropdown item with your finger, the RadButton click will also fire.

This issue does NOT occur on any desktop browser.

Is there any workaround for this?
Dimitar Terziev
Telerik team
 answered on 10 Jan 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?