Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
183 views
Hi, actually have used Kendo UI here and there. But never really understand the difference among those. Just know UI MVC is a wrapper to enable Kendo UI in MVC razor & Kendo UI is a Javascript UI library? How about UI AJAX? Please clarify. Thanks a lot!
Alex
Top achievements
Rank 1
 answered on 18 May 2016
2 answers
76 views

Installed UI for AJAX through .msi. i think it is installed because when i clicked it again. it detected the component. Then i am wondering how to create an UI for AJAX project? because all i have under 'Telerik' in 'File' -> 'New' -> 'Project' are UI for MVC & Kendo UI. Where is this UI for AJAX. Also, the docs on Telerik site are a big confusing, with all those for older ASP.NET versions and stuff. I didn't even find those assembles such as 'Telerik.Web.UI.dll', 'Telerik.Web.UI.Skins.dll' from 'Add Reference'.

 

Seriously, where is the right place to look at UI for AJAX or how to start at all?

Alex
Top achievements
Rank 1
 answered on 18 May 2016
4 answers
147 views
I have a RadlistView and RadDataPager working just fine, except that the pageSize dropdown at the top and the sort by: drop down at the bottom are disabled until the page postsback.  Here is my code:


<%@ Page Title="Favorite Candidates"  Language="VB" MasterPageFile="~/App_Masters/Interior.master" AutoEventWireup="false" CodeFile="FavoriteCandidates.aspx.vb" Inherits="School_FavoriteCandidates" %>
 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" Runat="Server">
 
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" VisibleOnPageLoad="True">
        <Windows>
            <telerik:RadWindow ID="RadWindow1" runat="server" Modal="True" NavigateUrl="CandidateNotes.aspx" VisibleOnPageLoad="False" Width="800px" AutoSize="true" AutoSizeBehaviors="HeightProportional" MinHeight="400px" MaxHeight="900px" Behaviors="Close, Move, Resize, Maximize"
                
                >
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
 
    <script type="text/javascript">
        /* Show new window */
        function ShowNewWindow(CandidateID) {
            //Show new window
            //not providing a name as a second parameter
            // creates a new window
            var oWindow = window.radopen("CandidateNotes.aspx?edit_id=" + CandidateID, null);
            //Using the reference to the window its clientside methods can be called
            oWindow.setSize(800, 400);
        }
 
</script>
 
    <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="false" />
    <div>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="ListViewPanel1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="ListViewPanel1" LoadingPanelID="RadAjaxLoadingPanel1">
                        </telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
            <ClientEvents OnRequestStart="RequestStart"></ClientEvents>
        </telerik:RadAjaxManager>
 
 
 
        <table>
            <tr>
                <td>
                    <h1>Favorite Candidates</h1>
                    <asp:Panel ID="ListViewPanel1" runat="server">
                        <telerik:RadListView ID="RadListView1" DataSourceID="SqlDataSource1" runat="server"
                            ItemPlaceholderID="CandidateContainer" DataKeyNames="CandidateID" AllowPaging="true"
                            OnItemCommand="RadListView1_ItemCommand" >
                            <LayoutTemplate>
                                <!-- Set the id of the wrapping container to match the CLIENT ID of the RadListView control to display the ajax loading panel
                         In case the listview is embedded in another server control, you will need to append the id of that server control -->
                                <fieldset id="FiledSet1" style="max-width946px;">
                                    <%--<legend>Candidates</legend>--%>
                                    <table cellpadding="0" cellspacing="0" width="100%">
                                        <tr>
                                            <td>
                                                <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="RadListView1"
                                                    PageSize="10" CssClass="pagerStyle" >
                                                    <Fields>
                                                        <telerik:RadDataPagerButtonField FieldType="FirstPrev"></telerik:RadDataPagerButtonField>
                                                        <telerik:RadDataPagerButtonField FieldType="Numeric" PageButtonCount="6"></telerik:RadDataPagerButtonField>
                                                        <telerik:RadDataPagerButtonField FieldType="NextLast"></telerik:RadDataPagerButtonField>
                                                        <telerik:RadDataPagerPageSizeField PageSizeComboWidth="60" PageSizeText="Page size: " />
                                                        <telerik:RadDataPagerGoToPageField CurrentPageText="Page: " TotalPageText="of" SubmitButtonText="Go"
                                                            TextBoxWidth="25"></telerik:RadDataPagerGoToPageField>
                                                        <telerik:RadDataPagerTemplatePageField>
                                                            <PagerTemplate>
                                                                <div style="floatrightpadding-left50px;">
                                                                    <b>
                                                                        <asp:Label runat="server" ID="CurrentPageLabel" Text="<%# IIF((Container.Owner.TotalRowCount > 0), Container.Owner.StartRowIndex + 1, 0)%>"></asp:Label>
                                                                        to
                                                                        <asp:Label runat="server" ID="TotalPagesLabel" Text="<%# IIF((Container.Owner.TotalRowCount > 0), Container.Owner.StartRowIndex + Container.Owner.PageSize, 0) %>"></asp:Label>
                                                                        of
                                                                        <asp:Label runat="server" ID="TotalItemsLabel" Text="<%# Container.Owner.TotalRowCount%>"></asp:Label>
                                                                    </b>
                                                                </div>
                                                            </PagerTemplate>
                                                        </telerik:RadDataPagerTemplatePageField>
                                                    </Fields>
                                                </telerik:RadDataPager>
                                            </td>
                                        </tr>
                                    </table>
                                    <asp:PlaceHolder ID="CandidateContainer" runat="server"></asp:PlaceHolder>
                                    <div style="clearboth">
                                    </div>
                                    <table style="width100%margin-top5px;">
                                        <tr>
                                            <td style="">
                                            </td>
                                            <td style="text-alignrightwidth75%;">
<asp:Label ID="lblSort1" runat="server" AssociatedControlID="ddListSort" Text="Sort by:"
Style="padding-right5px;"></asp:Label>
                                                <telerik:RadComboBox ID="ddListSort" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddListSort_SelectedIndexChanged">
                                                    <Items>
                                                        <telerik:RadComboBoxItem Text="-Select field to sort-" Value=""></telerik:RadComboBoxItem>
                                                        <telerik:RadComboBoxItem Text="Last Name" Value="NameLast"></telerik:RadComboBoxItem>
                                                        <telerik:RadComboBoxItem Text="First Name" Value="NameFirst"></telerik:RadComboBoxItem>
                                                        <telerik:RadComboBoxItem Text="Country" Value="Country"></telerik:RadComboBoxItem>
                                                        <telerik:RadComboBoxItem Text="Clear sort" Value="ClearSort"></telerik:RadComboBoxItem>
                                                    </Items>
                                                </telerik:RadComboBox>
<asp:RadioButtonList RepeatLayout="Flow" RepeatDirection="Horizontal" ID="rblSort"
runat="server" AutoPostBack="true" OnSelectedIndexChanged="rblSort_SelectedIndexChanged">
                                                    <asp:ListItem Text="Ascending" Value="ASC" Selected="True"></asp:ListItem>
                                                    <asp:ListItem Text="Descending" Value="DESC"></asp:ListItem>
                                                </asp:RadioButtonList>
                                            </td>
                                        </tr>
                                    </table>
                                </fieldset>
                            </LayoutTemplate>
                            <ItemTemplate>
                                <!--The widths/heights of the fieldset/outer tables in the item/edit/insert templates should match to avoid wrapping or visual discrepancies
                             in the tiles layout-->
                                <fieldset class="fieldset">
                                    <legend style="margin-bottom:0px;"> <a href="/School/Candidate.aspx?ID=<%# Eval("CandidateID")%>"><%# Eval("NameFirst")%> <%# Eval("NameLast")%></a> </legend>
                                    <table cellpadding="0" cellspacing="0" style="height100%;" width="100%">
                                        <tr>
                                            <td>
                                                <table cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td style="font-weight:bold;padding-right:5px;">
                                                            Positions Sought:
                                                        </td>
                                                        <td style="padding-right:5px;">
                                                            <%#Eval("CandidatePositions")%>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="font-weight:bold;padding-right:5px;">
                                                            Total Experience:
                                                        </td>
                                                        <td style="padding-right:5px;vertical-align:bottom;">
                                                            <%#Eval("ExperienceTotal")%>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="font-weight:bold;padding-right:5px;">
                                                            International Experience:
                                                        </td>
                                                        <td style="padding-right:5px;vertical-align:bottom;">
                                                            <%#Eval("ExperienceInternational")%>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="font-weight:bold;padding-right:5px;">
                                                            Available:
                                                        </td>
                                                        <td style="padding-right:5px;">
                                                            <%#Eval("StartMonth")%>/<%#Eval("StartYear")%></td>
                                                    </tr>
                                                    <tr>
                                                        <td style="font-weight:bold;padding-right:5px;">
                                                            Marital Status:
                                                        </td>
                                                        <td style="padding-right:5px;vertical-align:bottom;">
                                                            <%#Eval("MaritalStatus")%>
                                                        </td>
                                                    </tr>
                                                    <%#If(Eval("MaritalStatusID") <> 6, ("<tr><td style=""font-weight:bold;padding-right:5px;"">Partner Name:</td><td style=""vertical-align:bottom;"">" & Eval("PartnerNameFirst") & " " & Eval("PartnerNameLast") & "</td></tr>"), "")%>
                                                </table>
                                            </td>
                                            <td>
                                                <table cellpadding="0" cellspacing="0">                                                  
                                                    <tr>
                                                        <td style="font-weight:bold;padding-right:5px;">
                                                            Associate:
                                                        </td>
                                                        <td style="padding-right:5px;">
                                                            <%#Eval("AssocFirst")%> <%#Eval("AssocLast")%>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="font-weight:bold;padding-right:5px;">
                                                            Email:
                                                        </td>
                                                        <td style="padding-right:5px;">
                                                            <a href="mailto:<%#Eval("candEmail")%>"><%#Eval("candEmail")%></a>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="font-weight:bold;padding-right:5px;">
                                                            Skype:
                                                        </td>
                                                        <td style="padding-right:5px;">
                                                            <a href="skype:<%#Eval("candSkype")%>?call"><%#Eval("candSkype")%></a>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="font-weight:bold;padding-right:5px;">
                                                            Country:
                                                        </td>
                                                        <td style="padding-right:5px;">
                                                            <%#Eval("Country")%>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                            <td style="vertical-align:top;">
                                                <img src="/images/Candidates/c.<%# Eval("CandidateID")%>.jpg" alt="Candidate Photo"><br />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="text-alignright" colspan="3">
                                            </td>
                                        </tr>
                                    </table>
                                                <asp:panel ID="Panel1" runat="server">
                                                    <br /><a href="#" onclick="ShowNewWindow('<%# DataBinder.Eval(Container.DataItem, "CandidateID") %>'); return false;"><img src="/images/icons/notes.gif" style="width:22px;height:28px;vertical-align:middle" alt="Candidate Notes" />&nbsp;Notes</a>&nbsp;<asp:ImageButton runat="server" ID="cmdRemoveFromFavorites" ImageUrl="/images/icons/removeFavorite.gif" ToolTip="Remove From Favorites" Width="24px" Height="21px" ImageAlign="AbsMiddle" CommandName="remove" CommandArgument='<%# Eval("CandidateID")%>' />&nbsp;<asp:LinkButton ID="cmdLnkRemoveFromFavorites" runat="server" CommandName="remove" CommandArgument='<%# Eval("CandidateID")%>'>Remove Favorite</asp:LinkButton>
                                                </asp:panel>
                                </fieldset>
                            </ItemTemplate>
                            <EmptyDataTemplate>
                                <fieldset style="width100%">
                                    <legend>Favorites</legend>No favorite candidates available.
                                </fieldset>
                            </EmptyDataTemplate>
                        </telerik:RadListView>
                    </asp:Panel>
                </td>
            </tr>
        </table>
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Main %>"
            SelectCommand="SELECT blah blah"
            DeleteCommand="DELETE blah blah"
            UpdateCommand="UPDATE blah blah" 
            ConflictDetection="CompareAllValues" 
            OldValuesParameterFormatString="original_{0}">
            <DeleteParameters>
                <asp:Parameter Name="original_CandidateFavoriteID" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="original_CandidateID" Type="Int32" />
                <asp:Parameter Name="original_SchoolID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="CandidateID" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="SchoolID" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="original_CandidateFavoriteID" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="original_CandidateID" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="original_SchoolID" Type="Int32"></asp:Parameter>
            </UpdateParameters>
        </asp:SqlDataSource>
    </div>
</asp:Content>
 


Imports Telerik.Web.UI
Imports System.Data.SqlClient
Imports System.Configuration
 
Partial Class School_FavoriteCandidates
    Inherits System.Web.UI.Page
 
 
    Protected Sub Page_Load(sender As Object, e As System.EventArgsHandles Me.Load
        SiteUser.RequireSchoolLogon()
        SqlDataSource1.SelectCommand = "blah blah blah"
    End Sub
 
    Protected Sub RadListView1_ItemCommand(ByVal sender As ObjectByVal e As RadListViewCommandEventArgs)
        If (e.CommandName = RadListView.UpdateCommandName) OrElse (e.CommandName = RadListView.CancelCommandName) Then
            RadListView1.InsertItemPosition = RadListViewInsertItemPosition.None
 
            RadListView1.FindControl("btnInitInsert").Visible = True
        ElseIf String.Equals(e.CommandName, "remove"Then
            For Each myFave As SchoolFavorite In SiteUser.School.SchoolFavorites
                If myFave.CandidateID = e.CommandArgument Then
                    SiteUser.School.AddLogEntry("Removed " & myFave.Candidate.FullName & " from favorites""School")
                    myFave.Delete()
                    Exit For
                End If
            Next
            SiteUser.School.SchoolFavoritesReset()
            Response.Redirect("/School/FavoriteCandidates.aspx")
        End If
    End Sub
 
    Protected Sub ddListSort_SelectedIndexChanged(ByVal sender As ObjectByVal e As RadComboBoxSelectedIndexChangedEventArgs)
        Dim rbl As RadioButtonList = TryCast(RadListView1.FindControl("rblSort"), RadioButtonList)
 
        'check the e.Value passed as an argument and fire sort command for the corresponding field. The exact item in the listview from which you trigger the 
        'command is not important
        'FireCommandEvent method invokes Rebind() implicitly, hence no explicit call is needed to refresh the listview
        Select Case e.Value
            Case "NameLast"
                RadListView1.Items(0).FireCommandEvent(RadListView.SortCommandName, "NameLast")
                rbl.SelectedIndex = 0
                Exit Select
            Case "NameFirst"
                RadListView1.Items(0).FireCommandEvent(RadListView.SortCommandName, "NameFirst")
                rbl.SelectedIndex = 0
                Exit Select
            Case "Country"
                RadListView1.Items(0).FireCommandEvent(RadListView.SortCommandName, "Country")
                rbl.SelectedIndex = 0
                Exit Select
            Case "ClearSort"
                RadListView1.SortExpressions.Clear()
                RadListView1.Rebind()
                rbl.SelectedIndex = 0
                Exit Select
            Case Else
                Exit Select
        End Select
    End Sub
    Protected Sub rblSort_SelectedIndexChanged(ByVal sender As ObjectByVal e As EventArgs)
        Dim rbl As RadioButtonList = TryCast(sender, RadioButtonList)
        Dim combo As RadComboBox = TryCast(RadListView1.FindControl("ddListSort"), RadComboBox)
 
        'check the selected value passed as an argument and fire sort command for the corresponding field. The exact item in the listview from which you trigger the 
        'command is not important
        'FireCommandEvent method invokes Rebind() implicitly, hence no explicit call is needed to refresh the listview
 
        If combo.SelectedItem.Value.ToString() <> [String].Empty AndAlso combo.SelectedItem.Value.ToString() <> "ClearSort" Then
            Select Case rbl.SelectedValue
                Case "ASC"
                    RadListView1.Items(0).FireCommandEvent(RadListView.SortCommandName, combo.SelectedValue + " ASC")
                    Exit Select
                Case "DESC"
                    RadListView1.Items(0).FireCommandEvent(RadListView.SortCommandName, combo.SelectedValue + " DESC")
                    Exit Select
                Case Else
                    Exit Select
            End Select
        End If
    End Sub
 
 
End Class
Roger Chen
Top achievements
Rank 1
 answered on 17 May 2016
1 answer
222 views

Hello,

As the title says it, I would like to know how to get the value of a text box in my nestedViewTemplate while I am in the ItemCommand event.

When I cast the Telerik.Web.UI.GridCommandEventArgs e to a GridNestedViewItem, it says the cast is wonrg. If I cast it to GridDataItem, then my text box is after I used FindControl("myTextBoxID")

What would be the way to do that please?

 

Thank you

Gregory
Top achievements
Rank 2
 answered on 17 May 2016
4 answers
143 views

Here is the ASPX code:

<telerik:RadGrid ID="gvEditProjectPositions" Width="99.8%" AllowMultiRowEdit="False" AllowAutomaticDeleteCommand="false" Skin="Metro" runat="server" EnableLinqExpressions="False" GridLines="None" AutoGenerateColumns="False">
                                            <MasterTableView Width="100%" DataKeyNames="ProjectPositionID" CommandItemDisplay="Top" EnableColumnsViewState="False" EditMode="Batch">
                                                <CommandItemSettings SaveChangesText="Save to Grid" ShowCancelChangesButton="False" ShowRefreshButton="False" />
                                                <BatchEditingSettings EditType="Row" OpenEditingEvent="mousedown" />
                                                <Columns>
                                                    <telerik:GridButtonColumn HeaderStyle-Width="32px" ConfirmText="Delete this position?" ConfirmDialogType="RadWindow"
                                                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete"
                                                        ConfirmDialogHeight="160px" ConfirmDialogWidth="250px">
                                                        <ItemStyle HorizontalAlign="Right" />
                                                    </telerik:GridButtonColumn>
                                                    <telerik:GridBoundColumn DataField="ProjectPositionID" HeaderText="ID" UniqueName="ProjectPositionID" Display="False" />
                                                    <telerik:GridTemplateColumn DataField="PositionName" HeaderStyle-Width="170px" HeaderText="Position Name" UniqueName="PositionName">
                                                        <ItemTemplate>
                                                            <%# Eval("PositionName")%>
                                                        </ItemTemplate>
                                                        <ItemStyle HorizontalAlign="Right" />
                                                        <EditItemTemplate>
                                                            <asp:TextBox runat="server" ID="txtEditPositionName" MaxLength="100" Width="150px" CssClass="marginFix"></asp:TextBox>
                                                        </EditItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridTemplateColumn HeaderText="Staff - Unloaded Rate" HeaderStyle-Width="215px" UniqueName="Staff" DataField="StaffMemberID">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblEditProjectPositionStaff" runat="server" />
                                                        </ItemTemplate>
                                                        <ItemStyle HorizontalAlign="Right" />
                                                        <EditItemTemplate>
                                                            <asp:ObjectDataSource ID="StaffDataSource" TypeName="ResourcePlanner.service.StaffService" SelectMethod="GetActiveStaff" runat="server"></asp:ObjectDataSource>
                                                            <telerik:RadDropDownList ID="rddlStaff" runat="server"
                                                                DataSourceID="StaffDataSource" SelectedValue="StaffMemberID" DataValueField="StaffMemberID" DataTextField="NameRate" Width="205" AutoPostBack="True">
                                                            </telerik:RadDropDownList>
                                                        </EditItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridTemplateColumn DataField="LoadedRate" HeaderText="Loaded Rate" UniqueName="LoadedRate">
                                                        <ItemTemplate>
                                                            <%# Eval("LoadedRate", "{0:0.00}")%>
                                                        </ItemTemplate>
                                                        <ItemStyle HorizontalAlign="Right" />
                                                        <EditItemTemplate>
                                                            <telerik:RadNumericTextBox ID="txtEditLoadedRate" NumberFormat="{0:0.00}" DataType="System.Decimal" CssClass="tel-num-short-box" runat="server" />
                                                        </EditItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridNumericColumn DataField="PositionHours1Hours" HeaderText="Month 1" UniqueName="Month_1" ItemStyle-CssClass="tel-num-short-box" DecimalDigits="0" MaxLength="3">
                                                        <ItemStyle HorizontalAlign="Right" />
                                                    </telerik:GridNumericColumn>
                                                    <telerik:GridNumericColumn DataField="PositionHours2Hours" HeaderText="Month 2" UniqueName="Month_2" ItemStyle-CssClass="tel-num-short-box" DecimalDigits="0" MaxLength="3">
                                                        <ItemStyle HorizontalAlign="Right" />
                                                    </telerik:GridNumericColumn>
                                                    <telerik:GridNumericColumn DataField="PositionHours3Hours" HeaderText="Month 3" UniqueName="Month_3" ItemStyle-CssClass="tel-num-short-box" DecimalDigits="0" MaxLength="3">
                                                        <ItemStyle HorizontalAlign="Right" />
                                                    </telerik:GridNumericColumn>
                                                    <telerik:GridNumericColumn DataField="PositionHours4Hours" HeaderText="Month 4" UniqueName="Month_4" ItemStyle-CssClass="tel-num-short-box" DecimalDigits="0" MaxLength="3">
                                                        <ItemStyle HorizontalAlign="Right" />
                                                    </telerik:GridNumericColumn>
                                                    <telerik:GridNumericColumn DataField="PositionHours5Hours" HeaderText="Month 5" UniqueName="Month_5" ItemStyle-CssClass="tel-num-short-box" DecimalDigits="0" MaxLength="3">
                                                        <ItemStyle HorizontalAlign="Right" />
                                                    </telerik:GridNumericColumn>
                                                    <telerik:GridNumericColumn DataField="PositionHours6Hours" HeaderText="Month 6" UniqueName="Month_6" ItemStyle-CssClass="tel-num-short-box" DecimalDigits="0" MaxLength="3">
                                                        <ItemStyle HorizontalAlign="Right" />
                                                    </telerik:GridNumericColumn>
                                                    <telerik:GridNumericColumn DataField="PositionHours7Hours" HeaderText="Month 7" UniqueName="Month_7" ItemStyle-CssClass="tel-num-short-box" DecimalDigits="0" MaxLength="3">
                                                        <ItemStyle HorizontalAlign="Right" />
                                                    </telerik:GridNumericColumn>
                                                    <telerik:GridNumericColumn DataField="PositionHours8Hours" HeaderText="Month 8" UniqueName="Month_8" ItemStyle-CssClass="tel-num-short-box" DecimalDigits="0" MaxLength="3">
                                                        <ItemStyle HorizontalAlign="Right" />
                                                    </telerik:GridNumericColumn>
                                                    <telerik:GridNumericColumn DataField="PositionHours9Hours" HeaderText="Month 9" UniqueName="Month_9" ItemStyle-CssClass="tel-num-short-box" DecimalDigits="0" MaxLength="3">
                                                        <ItemStyle HorizontalAlign="Right" />
                                                    </telerik:GridNumericColumn>
                                                </Columns>
                                            </MasterTableView>
                                            <ClientSettings>
                                                <ClientEvents OnRowDblClick="RowDblClick" />
                                            </ClientSettings>
                                        </telerik:RadGrid>

Here is the code behind:

Private Sub gvEditProjectPositions_BatchEditCommand(sender As Object, e As GridBatchEditingEventArgs) Handles gvEditProjectPositions.BatchEditCommand
    Dim bSavedSuccessfully As Boolean = False
    Dim newValues As Hashtable
    Dim oldValues As Hashtable
    Try
        Dim staffInfo As List(Of domain.Staff) = StaffService.GetActiveStaff()
        For Each command As GridBatchEditingCommand In e.Commands
            'Ignore delete commands, we don't need to verify these.
            If (command.Type <> GridBatchEditingCommandType.Delete) Then
 
                newValues = command.NewValues
                oldValues = command.OldValues
                Dim countErrors As Integer
                'Loop through and make sure the positionname is not null or nothing and that the user is active.
                countErrors = projectDetail.Positions.Where(Function(p) String.IsNullOrEmpty(newValues("PositionName")) And (p.IsActive = "T")).Count
                If countErrors > 0 Then
                    ScriptManager.RegisterStartupScript(Me, Me.GetType(), "showErrorMessage", "showErrorMessage('Position Name cannot be left blank.');", True)
                    Exit Sub
                End If
                'Loop through and check for duplicate staff members, ignoring unassigned staffmembers, and ignoring the currently edited row.
                If (String.IsNullOrEmpty(newValues("StaffMemberID"))) Then
                    'newValues("StaffMemberID") = "0"
                End If
                countErrors = projectDetail.Positions.Where(Function(p) CLng(newValues("StaffMemberID")) <> 0 And p.StaffMemberID = CLng(newValues("StaffMemberID")) And CLng(newValues("ProjecID")) <> p.ProjectID).Count
                If (countErrors > 0) Then
                    ScriptManager.RegisterStartupScript(Me, Me.GetType(), "showErrorMessage", "showErrorMessage('Staff Members can only appear once within a grid.');", True)
                    Exit Sub
                End If
 
            End If
        Next
 
        'dim projectService as new ProjectsService(Master.clsCU.UserId)
        For Each command As GridBatchEditingCommand In e.Commands
            Dim projectPosition As domain.ProjectPosition
            newValues = command.NewValues
            oldValues = command.OldValues
            Dim positionId As Long = newValues("ProjectPositionID")
            Dim projectPositionService As New ProjectPositionService(Master.clsCU.UserId)
            If (command.Type = GridBatchEditingCommandType.Delete) Then
                'Delete the specified project position.
                projectPosition = projectDetail.Positions.FirstOrDefault(Function(p) p.ProjectPositionID = positionId)
                projectPosition.ProjectID = projectDetail.ProjectID
                projectPositionService.Delete(projectPosition)
            ElseIf (command.Type = GridBatchEditingCommandType.Update) Then
                'Update the specified Project
                projectPosition = projectPositionService.GetProjectPositionById(positionId)
                FillPositionFromHashtable(projectPosition, newValues)
                'projectPosition.Project = projectDetail
                projectPositionService.Update(projectPosition)
                For Each pph In projectPosition.ProjectPositionHours
                    Dim pphs As New ProjectPositionHoursService(Master.clsCU.UserId)
                    pph.ProjectPositionID = positionId
                    If pph.ProjectPositionHoursID > 3000 Then
                        pphs.Update(pph)
                    End If
                Next
            ElseIf (command.Type = GridBatchEditingCommandType.Insert) Then
                'Add a new project, with these details.
                projectPosition = New ProjectPosition()
                FillPositionFromHashtable(projectPosition, newValues)
                projectPosition.ProjectID = projectDetail.ProjectID
                projectPositionService.Insert(projectPosition)
                For Each pph In projectPosition.ProjectPositionHours
                    Dim pphs As New ProjectPositionHoursService(Master.clsCU.UserId)
                    pph.ProjectPositionID = positionId
                    If pph.ProjectPositionHoursID > 3000 Then
                        pphs.Insert(pph)
                    End If
                Next
            End If
        Next
        'This used to update the project positions, but nhibernate should be doing that for us!
        'projectDetail.Update()
        bSavedSuccessfully = True
    Catch ex As Exception
        ScriptManager.RegisterStartupScript(Me, Me.GetType(), "ReShowEditModal", "ReshowModal('#editProjectPositionsModal');", True)
        Support.LogError(ex, Master.clsCU.ID, True, Me)
    Finally
        If bSavedSuccessfully = True Then
            divEditProjectPosition.Visible = False
            LoadDetail(CLng(lvResults.SelectedDataKey(0)))
            ScriptManager.RegisterStartupScript(Me, Me.GetType(), "HideEditModal", "HideModal('#editProjectPositionsModal');", True)
        Else
            ScriptManager.RegisterStartupScript(Me, Me.GetType(), "HideEditModal", "HideModal('#editProjectPositionsModal');", True)
            ScriptManager.RegisterStartupScript(Me, Me.GetType(), "ShowEditModal", "ShowModal('#editProjectPositionsModal');", True)
 
        End If
 
    End Try
 
End Sub

New values for "StaffMemberID" is always "" but should be the selected value of the RadDropDownList, oldvalues does not even contain this item.

Adam
Top achievements
Rank 1
 answered on 17 May 2016
1 answer
111 views
It seems the OnClientBlur event is not firing with the latest version - unless you tab off the control.  If you blur by clicking your mouse outside of the combobox the event is not fired...  
Ivan Danchev
Telerik team
 answered on 17 May 2016
3 answers
308 views

I am using a radGrid which is inside an RadAjaxPanel.  I want to capture the DataKey value of Selected Row on a button Click Outside the Grid.   Though the button is also contained in the same RadAjaxPanel.   But Everytime I click the button, It returns 0 value for selected row.  I have tried using following code. 

 

 Protected Sub btnUpload_Click(sender As Object, e As EventArgs)
        Dim PersonEducationID As Long = -1      

        For Each item As GridDataItem In radEducationDetail.MasterTableView.Items
            If item.Selected Then
                Dim strKey As String = item.GetDataKeyValue("ID").ToString()
                PersonEducationID = strKey
            End If
        Next
    End Sub

 

Following is the design code for my grid

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">

                

                <telerik:RadGrid ID="radEducationDetail" AllowAutomaticUpdates="false" AllowAutomaticDeletes="true" AllowAutomaticInserts="false" OnItemDataBound="radEducationDetail_ItemDataBound" DataSourceID="sqlEducation"
                    AllowSorting="True" AllowPaging="True" runat="server" PageSize="50" Skin="WebBlue" MasterTableView-DataKeyNames="ID" AutoGenerateColumns="false" ShowGroupPanel="false"
                    EnableHierarchyExpandAll="false" EnableLinqExpressions="false" GridLines="None">
                    <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
                    <MasterTableView Width="100%" CommandItemDisplay="Top" Font-Bold="true" DataSourceID="sqlEducation" DataKeyNames="ID" AutoGenerateColumns="false" ShowGroupFooter="true">
                        <CommandItemSettings
                            AddNewRecordText="Add Education Detail"
                            RefreshImageUrl="../../Images/Refresh.png" />
                        <Columns>

                            <telerik:GridBoundColumn DataField="ID" HeaderText="ID" UniqueName="ID" SortExpression="ID" HeaderStyle-Font-Bold="true" ItemStyle-Font-Bold="false" Visible="false" />

                            <telerik:GridBoundColumn DataField="ProviderName" HeaderText="Provider Name" UniqueName="ProviderName" SortExpression="ProviderName" HeaderStyle-Font-Bold="true" ItemStyle-Font-Bold="false" />

                            <telerik:GridBoundColumn DataField="ProgramName" HeaderText="Program Name" UniqueName="ProgramName" SortExpression="ProgramName" HeaderStyle-Font-Bold="true" ItemStyle-Font-Bold="false" />

                            <telerik:GridBoundColumn DataField="EducationLevel" HeaderText="Education Level" UniqueName="EducationLevel" SortExpression="EducationLevel" HeaderStyle-Font-Bold="true" ItemStyle-Font-Bold="false" />

                            <telerik:GridBoundColumn DataField="StartDate" HeaderText="Start Date" SortExpression="StartDate" UniqueName="StartDate" DataType="System.DateTime" DataFormatString="{0:M/d/yyyy}" HeaderStyle-Font-Bold="true" ItemStyle-Font-Bold="false" />

                            <telerik:GridBoundColumn DataField="EndDate" HeaderText="EndDate" SortExpression="EndDate" UniqueName="EndDate" DataType="System.DateTime" DataFormatString="{0:M/d/yyyy}" HeaderStyle-Font-Bold="true" ItemStyle-Font-Bold="false" />

                            <telerik:GridEditCommandColumn ButtonType="LinkButton" UniqueName="EditCommandColumn" />

                            <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="LinkButton" UniqueName="DeleteCommandColumn" ConfirmText="Delete Row?" ConfirmTitle="Delete?" />

                        </Columns>

                        

                    </MasterTableView>
                    <ClientSettings AllowDragToGroup="true" AllowColumnsReorder="True">
                        <Selecting AllowRowSelect="True"></Selecting>
                    </ClientSettings>
                    <GroupingSettings ShowUnGroupButton="true" />
                </telerik:RadGrid>

                <div>
                    <br />
                    <table>
                        <tr>
                            <td>Upload Document:</td>
                            <td>
                                <asp:FileUpload ID="FileUploadJquery" runat="server" multiple="multiple" class="multi" ClientIdMode="Static" title="Browse" TabIndex="25" onchange="UploadEducationFiles();" /></td>
                            <td>
                                <asp:Button ID="btnUpload" runat="server" OnClick="btnUpload_Click" Text="Upload" /></td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <p id="demo"></p>
                            </td>
                        </tr>
                    </table>
                </div>

            </telerik:RadAjaxPanel>

I also tried to enable Autopostback on row selection but that did not help. 

Can you please suggest me why is this happening. I am struggling from hours now. 

Viktor Tachev
Telerik team
 answered on 17 May 2016
12 answers
674 views
Hi,

Please help in the following issue .
The asp.net validator controls (like required field validator, compare validator etc) are firing after the postback (when the submit or rad grid insert button is pressed). This is happening in the case when the RadAjaxPanel is used.



Thanks & Regards,
AbdulRahman
TCS
Maria Ilieva
Telerik team
 answered on 17 May 2016
2 answers
210 views

Hi,

I have problem with export to csv footer total.In scv file not display footer total.
When I export the same data into pdf, i have no problem.


Thanks,
Igor

suyash
Top achievements
Rank 1
 answered on 17 May 2016
3 answers
276 views
I'm using a RadGrid in a multi-language/multi-cultural web application.  This grid contains columns with fractional Width values and am seeing the rendered HTML is invalid when the page's culture is set to one that uses commas for decimal places.  To recreate the issue, I created a very simple web app with a RadGrid and added a GridDateTimeColumn defined like this:

<telerik:RadGrid runat="server" ID="RadGrid1">
  <MasterTableView>
    <Columns>
      <telerik:GridDateTimeColumn HeaderStyle-Width="10.5em" UniqueName="Col1" DataField="Col1" />
      <telerik:GridDateTimeColumn HeaderStyle-Width="15.8em" UniqueName="Col2" DataField="Col2" />
    </Columns>
  </MasterTableView>
</telerik:RadGrid>

When setting the Page's Culture property to one that uses a comma as the decimal place (for example "fr-FR") the rendered grid also has the format applied to the property value, which is certainly undesirable.  In Internet Explorer, these invalid strings are ignored and replaced with an empty property value, however Chrome renders these grids as follows:

<table class="rgMasterTable" id="RadGrid1_ctl00" style="width:100%;table-layout:auto;empty-cells:show;">
  <colgroup>
    <col style="width:10,5em" />
    <col style="width:15,8em" />
  </colgroup>
<thead>

While the browsers appear to output some default column widths (thus ignoring the invalid values), where things really go wrong is when trying to persist the grid's settings using a RadPersistenceManager.  When trying to reload the grid's columns widths, an error is encountered due to trying to load the invalid number formats, or in other cases the grid is rendered with the columns completely missing from the display.

I'm not sure if it's against best practice to use fractional values for Width properties, but we have done this in a number of places in our application and it does not appear to be a problem with generic ASP.NET controls such as GridViews where they aren't trying to apply a format to a property value.

I would appreciate some guidance... are we violating a best practice, missing something obvious, or is this a bug in the RadGrid, column control, or (less likely) the RadPersistenceManager?


I'm running the 2016-Q2 release of the controls and am developing in a .NET 4.5 application.

Konstantin Dikov
Telerik team
 answered on 17 May 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Andrey
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Andrey
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?