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

The following code produces 'test' message on initial load, before actual click.

 

  <telerik:RadImageTile ID="ritTREDAIR" Name="TREDAir"
                                   Height="385" Width="340px"
                                   runat="server"
                                   OnClientClicking="alert('test')">
                    <Title Text="TREDAir"></Title>
  </telerik:RadImageTile>

Am i doing something wrong?

Vessy
Telerik team
 answered on 08 Aug 2018
8 answers
288 views

Hello,

I have an old style ASP .NET AJAX SharePoint web part with a user control that has a grid on it. I have a Search button which, when clicked, posts back to the server and populates the grid with search results based on search text. In IE11 everything works fine. In Chrome (and Edge), the first search works, but subsequent searches do not refresh the grid. In debug mode, I see the server code works correctly to retrieve the data, data bind and rebind the results, but those results never get back to the client and the grid is not refreshed. I repeat - everything works correctly in IE.

I also noticed that on the second search, when the server is finished, none of the client side JavaScript is executed - e.g. I added an alert which is never executed.

I need some guidance on how to identify the problem, or if this is a known issue.

Chrome: Version 67.0.3396.99 (Official Build) (64-bit)

IE: 11.165.17134.0 Update version: 11.0.75

Telerik: v4.0_2017.3.913

Thank you

Eyup
Telerik team
 answered on 08 Aug 2018
17 answers
915 views
I have a grid with grouping by state.  At each level I have check boxes (Header, Group, Detail).  If the header is checked, all check boxes are checked.  If a group check box is checked, all detail check boxes in that group are checked.  If a detail check box is unchecked, the group needs to be unchecked and the header needs to be unchecked.  I had to write custom code for this because I could find no imbedded controls to do this for me.  I used the code example Select All option in Grid Header along with individual group selection as a starting point.  My problem is that this is all done server side.  I would like it to be client side.  I found client side examples that let me select all, but none that did the unselecting when a lower item was unchecked.  I have made several attempts at writing the client side code, but have failed.

I am using telerik version 2012.3.1016.4, Visual Basic .Net Framework 4.  This needs to work in all (most common) browsers.

My aspx page
<form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <div>
        <br />
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowMultiRowSelection="true"  DataSourceID="SqlDataSource1" GridLines="None" AutoGenerateColumns="False" OnItemCreated="RadGrid1_ItemCreated" Skin="Hay">
            <MasterTableView DataSourceID="SqlDataSource1">
                <RowIndicatorColumn Visible="False">
                    <HeaderStyle Width="20px" />
                </RowIndicatorColumn>
                <ExpandCollapseColumn Resizable="False" Visible="False">
                    <HeaderStyle Width="40px" />
                </ExpandCollapseColumn>
                <GroupByExpressions>
                  <telerik:GridGroupByExpression>
                   <GroupByFields>
                     <telerik:GridGroupByField FieldName="State" FieldAlias="State" />
                   </GroupByFields>
                   <SelectFields>
                     <telerik:GridGroupByField FieldName="State" FieldAlias="State" />
                   </SelectFields>
                  </telerik:GridGroupByExpression>
                </GroupByExpressions>
                <Columns>
                <telerik:GridBoundColumn SortExpression="LastName" HeaderText="Last Name" HeaderButtonType="TextButton"
                    DataField="LastName" UniqueName="LastName" ItemStyle-Width="40px" >
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn SortExpression="FirstName" HeaderText="First Name" HeaderButtonType="TextButton"
                    DataField="FirstName" UniqueName="FirstName">
                </telerik:GridBoundColumn>
                </Columns>
                <EditFormSettings>
                    <PopUpSettings ScrollBars="None" />
                </EditFormSettings>
            </MasterTableView>
        </telerik:RadGrid><br />
        <br />
    <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:ConnString %>"
        ProviderName="System.Data.SqlClient" SelectCommand="select * from TAZTestData order by State, LastName"
        runat="server">
    </asp:SqlDataSource>
         </div>
</form>

My vb.net code
Protected Sub RadGrid1_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs)
    If TypeOf e.Item Is GridHeaderItem Then
        Dim header As GridHeaderItem = DirectCast(e.Item, GridHeaderItem)
        Dim headerchkbx As New CheckBox()
        headerchkbx.ID = "CheckBox1"
        headerchkbx.AutoPostBack = True
        AddHandler headerchkbx.CheckedChanged, AddressOf headerchkbx_CheckedChanged
        header("column").Controls.Add(headerchkbx)
    End If
    If TypeOf e.Item Is GridGroupHeaderItem Then
        Dim header As GridGroupHeaderItem = DirectCast(e.Item, GridGroupHeaderItem)
        Dim groupchkbx As New CheckBox()
        groupchkbx.ID = "CheckBox2"
        groupchkbx.AutoPostBack = True
        AddHandler groupchkbx.CheckedChanged, AddressOf groupchkbx_CheckedChanged
        header.Controls(0).Controls.Add(groupchkbx)
    End If
    If TypeOf e.Item Is GridDataItem Then
        Dim header As GridDataItem = DirectCast(e.Item, GridDataItem)
        Dim detailchkbx As New CheckBox()
        detailchkbx.ID = "CheckBox3"
        detailchkbx.AutoPostBack = True
        AddHandler detailchkbx.CheckedChanged, AddressOf detailchkbx_CheckedChanged
        header.Controls(0).Controls.Add(detailchkbx)
    End If
 
End Sub
 
Private Sub headerchkbx_CheckedChanged(sender As Object, e As EventArgs)
 
    Dim headerchkbx As CheckBox = DirectCast(sender, CheckBox)
    For Each groupHeader As GridGroupHeaderItem In RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader)
        Dim children As GridItem() = groupHeader.GetChildItems()
        Dim groupchkbx As CheckBox = DirectCast(groupHeader.Controls(0).FindControl("CheckBox2"), CheckBox)
        For Each child As GridItem In children
            Dim detailchkbx As CheckBox = DirectCast(child.Controls(0).FindControl("CheckBox3"), CheckBox)
            detailchkbx.Checked = headerchkbx.Checked
        Next
 
        ' If headerchkbx.Checked Then
        groupchkbx.Checked = headerchkbx.Checked
        'Else
        'item.Selected = False
        'groupchkbx.Checked = False
 
        'End If
    Next
    For Each item As GridHeaderItem In RadGrid1.MasterTableView.GetItems(GridItemType.Header)
        item.Selected = headerchkbx.Checked
    Next
End Sub
 
Private Sub groupchkbx_CheckedChanged(sender As Object, e As EventArgs)
    Dim chkCount As Integer = 0
    For Each groupHeader As GridGroupHeaderItem In RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader)
        Dim children As GridItem() = groupHeader.GetChildItems()
 
        Dim groupchkbx As CheckBox = DirectCast(groupHeader.Controls(0).FindControl("CheckBox2"), CheckBox)
        If (groupchkbx.Checked) Then
            chkCount += 1
        End If
        For Each child As GridItem In children
            Dim detailchkbx As CheckBox = DirectCast(child.Controls(0).FindControl("CheckBox3"), CheckBox)
            detailchkbx.Checked = groupchkbx.Checked
            'Dim dataItem As GridDataItem = TryCast(child, GridDataItem)
            'dataItem.Selected = groupchkbx.Checked
 
            For Each item As GridHeaderItem In RadGrid1.MasterTableView.GetItems(GridItemType.Header)
                Dim headerchkbx As CheckBox = DirectCast(item("column").FindControl("CheckBox1"), CheckBox)
 
                If (Not groupchkbx.Checked) Then
                    headerchkbx.Checked = False
                End If
                If RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader).Length = chkCount Then
                    headerchkbx.Checked = True
 
                End If
            Next
        Next
    Next
End Sub
 
Private Sub detailchkbx_CheckedChanged(sender As Object, e As EventArgs)
    Dim totalCount As Integer = 0
    Dim groupCount As Integer = 0
    Dim totalChkCount As Integer = 0
    Dim groupChkCount As Integer = 0
    'Loop through all groups
    For Each groupHeader As GridGroupHeaderItem In RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader)
        Dim groupchkbx As CheckBox = DirectCast(groupHeader.Controls(0).FindControl("CheckBox2"), CheckBox)
        Dim grpChildren As GridItem() = groupHeader.GetChildItems()
 
        For Each child As GridItem In grpChildren
            'Count total number of checkboxes in whole grid and in each group
            totalCount += 1
            groupCount += 1
            Dim detailchkbx As CheckBox = DirectCast(child.Controls(0).FindControl("CheckBox3"), CheckBox)
            'Count number of checkboxes that are checked in whole grid and in each group
            If (detailchkbx.Checked) Then
                totalChkCount += 1
                groupChkCount += 1
            End If
        Next
        'Check the group check box if all the children are checked
        If groupCount = groupChkCount Then
            groupchkbx.Checked = True
        Else
            groupchkbx.Checked = False
        End If
        groupCount = 0
        groupChkCount = 0
    Next
    For Each hdr As GridHeaderItem In RadGrid1.MasterTableView.GetItems(GridItemType.Header)
        Dim headerchkbx As CheckBox = DirectCast(hdr("column").FindControl("CheckBox1"), CheckBox)
        If totalCount = totalChkCount Then
            headerchkbx.Checked = True
        Else
            headerchkbx.Checked = False
        End If
    Next
End Sub

Thank you for any help!
Eyup
Telerik team
 answered on 08 Aug 2018
5 answers
399 views
I have a grid that is setup very similar to the example for Grid / Hierarchy with Templates.

That is I have a RadGrid with a NestedViewTemplate.  In that template I have an asp:Panel and in that I have a RadTabStrip.  The first page view contains a label with a key value for EmployeeID and a RadGrid that uses that label to get the data and populate that grid.  Just like the example.

However, I need to edit and insert items into that grid that is in the first tab of the strip in the nested view.  I have  an ascx file that I'm using for that purpose.  Edit works just fine.  When I insert, however, I need to access that value from the label to put in the database as the foreign key.  The insert function seems to wipe all the data from the binding expressions used in the ascx page.  All of the code samples I've seen don't cover the ascx file for inserts.

<MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="EmployeeID" AllowMultiColumnSorting="True" 
                GroupLoadMode="Server">  
                <NestedViewTemplate> 
                    <asp:Panel runat="server" ID="InnerContainer" CssClass="viewWrap" Visible="false">  
                        <telerik:RadTabStrip runat="server" ID="TabStip1" MultiPageID="Multipage1" 
                            SelectedIndex="0">  
                            <Tabs> 
                                <telerik:RadTab runat="server" Text="Sales" PageViewID="PageView1">  
                                </telerik:RadTab> 
                                <telerik:RadTab runat="server" Text="Contact Information" PageViewID="PageView2">  
                                </telerik:RadTab> 
                                <telerik:RadTab runat="server" Text="Statistics Chart" PageViewID="PageView3">  
                                </telerik:RadTab> 
                            </Tabs> 
                        </telerik:RadTabStrip> 
                        <telerik:RadMultiPage runat="server" ID="Multipage1" SelectedIndex="0" RenderSelectedPageOnly="false">  
                            <telerik:RadPageView runat="server" ID="PageView1">  
                                <asp:Label ID="Label1" Font-Bold="true" Font-Italic="true" Text='<%# Eval("EmployeeID") %>' 
                                    Visible="false" runat="server" /> 
                                <telerik:RadGrid runat="server" ID="OrdersGrid" DataSourceID="SqlDataSource2" 
                                    ShowFooter="true" AllowSorting="true" EnableLinqExpressions="false">  
                                    <MasterTableView ShowHeader="true" AutoGenerateColumns="False" AllowPaging="true" 
                                        DataKeyNames="OrderID" PageSize="7" HierarchyLoadMode="ServerOnDemand"

To use the ID's from the example, I need the OrdersGrid to function where the insert form is an ascx page and it needs to know the value of Label1 in PageView1.  Oh, and my OrdersGrid doesn't have any detail tables.

The ascx page has a button on it:
<asp:Button ID="btnUpdate"    
                    Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update"%>'   
                    runat="server"   
                    CommandName='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'   
                    onclick="btnUpdate_Click"/> 

and that button event needs to be able to reference the label.
protected void btnUpdate_Click(object sender, EventArgs e)  
        {  
            if (btnUpdate.Text == "Update")  
            {  
               //This works swimmingly with the bindings from the form  
            }  
            if (btnUpdate.Text == "Insert")  
            {  
               //This doesn't work because I can't pass the datakey that is in the label. Using the insert 
                command button on the grid clears the data sent to the form.  
            }  
        } 


I'm assuming I can put something in the page load event of the ascx page to access the value of that label, but I don't have any idea where to begin.

Thanks in advance.
Eyup
Telerik team
 answered on 07 Aug 2018
3 answers
505 views

Hi, I'm having troubles removing a blank row in my export file (See example1);

The only thing I have between the rows is an "EditItemTemplate" where I update the row.(check example2).
Is that what's causing it?

My export code:

            gridOrdenes.ExportSettings.IgnorePaging = true;
            gridOrdenes.ExportSettings.ExportOnlyData = true;
            gridOrdenes.ExportSettings.OpenInNewWindow = true;
            gridOrdenes.ExportSettings.HideStructureColumns = true;
            gridOrdenes.MasterTableView.ExportToExcel();

Thank you.
Vessy
Telerik team
 answered on 07 Aug 2018
2 answers
345 views

I have been struggling to get the callback function to be recognized.  My situation is that I have a javascript function that executes when a user clicks a button.  This function contains code similar to the following to open the radconfirm prompt window

 var oManager = GetRadWindowManager();
    oManager.radconfirm(pMsg, "returnFunction",400,300,"Popup Title");

 

When the user clickes either the Ok or Cancel button the following error occurs.

JavaScript runtime error: Function expected

 

The function returnFunction(arg) exsits in the same javascript file but is not recognized.

Any ideas as to the issue.

 

Andy
Top achievements
Rank 1
Iron
 answered on 06 Aug 2018
1 answer
137 views

I would like to be able to remove formatting when pasting into the spreadsheet control. I have followed the recommendation on this article.

https://docs.telerik.com/devtools/aspnet-ajax/controls/spreadsheet/how-to/pasting-data-only

However, this._content is always undefined.

What am I missing? I am using version 2016.2.607.45

Marin Bratanov
Telerik team
 answered on 06 Aug 2018
3 answers
386 views
I am looking into your editor HTML to PDF conversion demo: http://demos.telerik.com/aspnet-ajax/editor/examples/pdfexport/defaultcs.aspx and converting the editor to PDF only converts the visible content. If you scroll further down the editor content, you placed a table with browser info and graphics in it, but this data does not render to the pdf, Why?
Is this the only example you have on your site?
Is the pdf conversion tool unable to convert form elements (checkboxes, textboxes) into pdf?
What HTML elements can the generator convert to pdf?
Rumen
Telerik team
 answered on 06 Aug 2018
5 answers
250 views
I have a GridHyperLinkColumn in my radgrid that is used to link to a SSRS report on a per-row basis - I would like to add a header link button that allows the users to execute a report that generates a report of all row items (1 record per-page).  To my mind setting the HeaderImageUrl and HeaderButtonType to LinkButton should result in a HyperLink control being rendered in the header cell however that is not the case - all I get is a Image control with the referenced image I set.  It appears that setting the HeaderButtonType has no effect so I'm wondering what column types is this property valid for as it does not seem to be valid for a GridHyperLinkColumn.  Obviously I could use a template column but I thought if I could use the properties provided (HeaderImageUrl/HeaderButtonType) life could be much simpler - that appears to not be the case.

<telerik:GridHyperLinkColumn UniqueName="MemoColumn" ImageUrl="Content/Images/memo16.png" Target="_blank"
                                    HeaderImageUrl="Content/Images/memo16.png" HeaderButtonType="LinkButton">
                                    <ItemStyle HorizontalAlign="Center" Width="3%" Wrap="false" />
                                    <HeaderStyle HorizontalAlign="Center" Width="3%" />
                                </telerik:GridHyperLinkColumn>
Eyup
Telerik team
 answered on 06 Aug 2018
3 answers
390 views

I have a link button in my RadGrid. When I clicked the link button,it will pop out a new page. All is working fine without error. Here is my code:


ASP
<telerik:RadGrid ID="gvCustomer" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" CellSpacing="0" GridLines="None" Width="100%">
        <MasterTableView AllowMultiColumnSorting="True">
            <CommandItemSettings ExportToPdfText="Export to PDF" />
            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
            </RowIndicatorColumn>
            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn column" HeaderText="Customer Name"
                    SortExpression="CUSTOMERNAME" UniqueName="TemplateColumn">
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkCustomerName" runat="server" CommandArgument='<%#Eval("CUSTOMERNAME") "," +Eval("IC")+ "," +Eval("ACCNO")%>' 
   CommandName="command" Font-Underline="True" Text='<%# Bind("CUSTOMERNAME") %>'>
 </
asp:LinkButton>
                    </ItemTemplate>
                    <FooterStyle HorizontalAlign="Center" />
                    <HeaderStyle Width="25%" />
                    <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />
                </telerik:GridTemplateColumn>
            </Columns>
            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
            <PagerStyle AlwaysVisible="True" />
        </MasterTableView>
        <HeaderStyle HorizontalAlign="Center" />
        <PagerStyle AlwaysVisible="True" />
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
</telerik:RadGrid>

VB.NET
Protected Sub gvCustomer_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles gvCustomer.ItemCommand
 
       If e.CommandName = "command" Then
           Dim arg As String() = e.CommandArgument.ToString.Split(",")
           Dim strName As String = arg(1)
           Dim strIC As String = arg(2)
           Dim strAccountNo As String = arg(3)
 
           Dim str As String
           str = "<script language='javascript'>window.open(' " + "~/Customer.aspx?CustomerName=" & strName & "&OldIC=" & strIC & "&AccountNo=" & strAccountNo + " ');</script>"
           ClientScript.RegisterStartupScript(Me.GetType(), "script", str)
       End If
   End Sub

But after I added the RadAjaxManager to handle the RadGrid. The link button is not working anymore. The new page does not pop out. But if I remove the ajax manager will work fine,the page is post back and new page is pop out. Below is the code I added:


ASP
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="gvCustomer">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="gvCustomer" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
</telerik:RadAjaxManager>

Please help me to find out the solution.Thank you very much!
Attila Antal
Telerik team
 answered on 06 Aug 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?