Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
112 views
I have a user control that contains a RadGrid with the EditLink column,

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Prospects.ascx.cs" Inherits="Prospects" %>  
    <telerik:RadCodeBlock ID="radcodeProspects" runat="server">
        <script type="text/javascript">
            function ShowEditForm(id, rowIndex) {
                alert(id);
                window.radopen("EditContact.aspx?ContactID=" + id, "UserListDialog");
                return false;
            }
            function ShowInsertForm() {
                window.radopen("EditContact.aspx", "UserListDialog");
                return false;
            }
            function refreshGrid(arg) {
                if (!arg) {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
                }
                else {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");
                }
            }
  
        </script>
    </telerik:RadCodeBlock>
     <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="prospectGrid" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="prospectGrid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="prospectGrid" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
  
    <telerik:RadGrid AllowSorting="true" BackColor="#393939"
        ID="prospectGrid" runat="server" AllowPaging="true" PageSize="15" 
        Width="980px" CssClass="productsGrid" 
        OnPreRender="prospectGrid_PreRender"  OnItemCreated="prospectGrid_ItemCreated"
        OnNeedDataSource="prospectGrid_NeedDataSource" style="outline:0">
        <MasterTableView AutoGenerateColumns="false" PagerStyle-Mode="NextPrevAndNumeric" AllowFilteringByColumn="false"
                         DataKeyNames="OrderID" ClientDataKeyNames="OrderID" TableLayout="Fixed">
            <Columns>
                <telerik:GridBoundColumn DataField="OrderID" HeaderText="ProspectID" AutoPostBackOnFilter="true" ShowFilterIcon="false" HeaderStyle-Width="70px"  FilterControlWidth="35px">
                </telerik:GridBoundColumn>
                <telerik:GridNumericColumn DataField="Freight" HeaderText="Freight" DataFormatString="{0:c}" HeaderStyle-Width="110px" FilterControlWidth="60px">
                </telerik:GridNumericColumn>
                <telerik:GridBoundColumn DataField="ShipName" HeaderText="Prospect Name" HeaderStyle-Width="300px" FilterControlWidth="260px">
                </telerik:GridBoundColumn>      
                <telerik:GridBoundColumn DataField="ShipCountry" HeaderText="Country" FilterControlWidth="70px">
                </telerik:GridBoundColumn>
                <telerik:GridDateTimeColumn DataField="OrderDate" HeaderText="Order Date" DataFormatString="{0:d}" FilterControlWidth="95px">
                </telerik:GridDateTimeColumn>
                <telerik:GridDateTimeColumn DataField="ShippedDate" HeaderText="Shipping Date" DataFormatString="{0:d}" FilterControlWidth="95px">
                </telerik:GridDateTimeColumn>
                <telerik:GridTemplateColumn UniqueName="TemplateEditColumn">
                    <ItemTemplate>
                        <asp:HyperLink ID="EditLink" runat="server" Text="Edit"></asp:HyperLink>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings AllowDragToGroup="false" EnableRowHoverStyle="true">
            <Selecting AllowRowSelect="true" />
            <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="360px" />
        </ClientSettings>
    </telerik:RadGrid>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true">
            <Windows>
                <telerik:RadWindow ID="UserListDialog" runat="server" Title="Editing record" Height="320px"
                    Width="310px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false"
                    Modal="true" />
            </Windows>
    </telerik:RadWindowManager>
  
    <telerik:RadAjaxLoadingPanel ID="ProductsLoadingPanel" runat="server"></telerik:RadAjaxLoadingPanel>

and the onClick code is generated in the code-behind file,

protected void prospectGrid_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            HyperLink editLink = (HyperLink)e.Item.FindControl("EditLink");
            editLink.Attributes["href"] = "#";
            editLink.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["OrderID"], e.Item.ItemIndex);
        }
    }
  
    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        if (e.Argument == "Rebind")
        {
            prospectGrid.MasterTableView.SortExpressions.Clear();
            prospectGrid.MasterTableView.GroupByExpressions.Clear();
            prospectGrid.Rebind();
        }
        else if (e.Argument == "RebindAndNavigate")
        {
            prospectGrid.MasterTableView.SortExpressions.Clear();
            prospectGrid.MasterTableView.GroupByExpressions.Clear();
            prospectGrid.MasterTableView.CurrentPageIndex = prospectGrid.MasterTableView.PageCount - 1;
            prospectGrid.Rebind();
        }
    }

but whenever I click on the EditLink hyperlink I get the Microsoft JScript runtime error: Object expected exception.

My default.aspx RadScriptManager code,

<telerik:RadScriptManager runat="server" ID="RadScriptManager1">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Path="~/Scripts/jquery.maphilight.min.js" />
            <asp:ScriptReference Path="~/Scripts/maphilight.js" />
        </Scripts>
    </telerik:RadScriptManager>



any help will be appreciated.
Mira
Telerik team
 answered on 08 Jul 2011
1 answer
50 views
In firefox, pressing backspace with in a delayfiltered filter box causes a postback after the delay. in IE8 and chrome it doesn't.

Full steps
1) Go to This rad grid demo page
2) put '2' in the order id column and wait for 4 seconds. The page reloads with the new filter (no results, but it doesn't matter what the text is).
3) Click on the field so that the cursor is to the right of the text.
4) Press backspace and wait for 4 seconds.
5-firefox) grid postbacks and updates as I expect it should.
5-ie-or-chrome) grid doesn't postback. Pressing enter does the postback (almost a valid workaround).

I think it should do the post back, but most of all I think it should be consistent.

Greg.
Tsvetoslav
Telerik team
 answered on 08 Jul 2011
3 answers
85 views
Hi all,

I've just started using the Telerik controls and I'm looking for some advice on how to achieve the requirement below.

I'd like the user to be able to choose a 'Create' option from a context menu on a tree view node.

On selecting this option, I'd like to display a Telerik Window to enable the user to create a new record. If this is too difficult, I'm happy for this to be some other UI element and I'm open to suggestion here.

On saving the record, I'd like to add the newly created item into the tree node.

1. Are there any code samples on how to open up a Window or form from a context menu item?

2. I'm trying to figure out the code that's needed to add items into the treeview and I'm following the article beneath.

http://www.telerik.com/help/aspnet-ajax/treeview-general-add-node-in-edit-mode-by-default.html

When I add the following javascript into my page, I get the following error when loading the page.

function HighlightNode(value) {
    var tree = $find("<%= RadTreeView1.ClientID %>");
    var node = tree.findNodeByValue(value);
    if (node != null) {
        node.startEdit();
    }
}


The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

I’m not sure if this is relevant but I've added a RadAjaxManager onto my page and am using the code beneath in the AddNode method.
Dim script As String = "HighlightNode(""" + newNode.Value + """)"
RadAjaxManager1.ResponseScripts.Add(script)

Any help or guidance would be much appreciated.

Tim
Tim
Top achievements
Rank 1
 answered on 08 Jul 2011
9 answers
251 views
Is it possible to open the RadGrid Popup Edit window manually? I would like to open it when clicking the update button so I can capture additional information from the user. 
William
Top achievements
Rank 1
 answered on 08 Jul 2011
5 answers
118 views
I have a NestedViewTemplate within a RadGrid.  Within the NestedViewTemplate I have two other Rad-grids showing data to the parent RadGrid.  The 'select' operation on both nested RadGrid's work fine.  However, when attempting to delete a record in one of the nested RadGrid, nothing happens.  Please review the below code and advise:

 

<telerik:RadGrid ID="RadGrid2" DataSourceID="SqlDataSource3" GridLines="None" ShowGroupPanel="False" Skin="WebBlue" runat="server"

 

 

AutoGenerateEditColumn="True" AllowAutomaticInserts="true" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true">

 

 

<ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true" HideStructureColumns="true"></ExportSettings>

 

 

<MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource3"

 

 

ShowHeader="True" AllowPaging="false" CommandItemDisplay="Top">

 

 

<Columns>

 

 

<telerik:GridBoundColumn DataField="intInspectorID" DataType="System.Int32" HeaderText="intInspectorID"

 

 

SortExpression="intInspectorID" UniqueName="intInspectorID" Visible="false" ReadOnly="true">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="intCertificationID" DataType="System.Int32" HeaderText="intCertificationID"

 

 

SortExpression="intCertificationID" UniqueName="intCertificationID" Visible="false" ReadOnly="true">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="strCertificationDesc" HeaderText="Certification" SortExpression="strCertificationDesc"

 

 

UniqueName="strCertificationDesc">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="dtmDateExpires" HeaderText="Date Expires" SortExpression="dtmDateExpires"

 

 

UniqueName="dtmDateExpires">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridButtonColumn ConfirmText="Delete this Certification?" ButtonType="LinkButton"

 

 

CommandName="Delete" Text="Delete" UniqueName="DeleteColumn1">

 

 

<HeaderStyle Width="20px" />

 

 

<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />

 

 

</telerik:GridButtonColumn>

 

 

</Columns>

 

 

<EditFormSettings EditFormType="Template">

 

 

<FormTemplate>

 

 

<table style="width:100%; table-layout:fixed; margin: 0 0 0 0; background-color:#E6E6E6;">

 

 

<tr>

 

 

<td align="right" style=" vertical-align:top;">

 

 

<asp:Label ID="Label3" runat="server" Text="Certification:"></asp:Label>

 

 

</td>

 

 

<td align="left">

 

 

<telerik:RadComboBox ID="cboStateEdit" runat="server" DataTextField='<%# Bind("strCertificationDesc") %>'

 

 

DataValueField='<%# Bind("intCertificationID") %>' Text='<%# Bind("strCertificationDesc") %>'

 

 

SelectedValue='<%# Bind("intCertificationID") %>' Skin="WebBlue">

 

 

<Items>

 

 

<telerik:RadComboBoxItem Text="--Select--" Value="" />

 

 

<telerik:RadComboBoxItem Text="NICET" Value="1" />

 

 

<telerik:RadComboBoxItem Text="NICEPT" Value="2" />

 

 

<telerik:RadComboBoxItem Text="ACI" Value="3" />

 

 

<telerik:RadComboBoxItem Text="PennDOT Concrete" Value="4" />

 

 

</Items>

 

 

</telerik:RadComboBox>

 

 

</td>

 

 

</tr>

 

 

<tr>

 

 

<td align="right" style=" vertical-align:top;">

 

 

<asp:Label ID="Label15" runat="server" Text="Date Expires:"></asp:Label>

 

 

</td>

 

 

<td align="left">

 

 

<telerik:RadDatePicker ID="RadDatePicker1" runat="server"

 

 

DbSelectedDate='<%# Bind("dtmDateExpires") %>' EnableTyping="false">

 

 

</telerik:RadDatePicker>

 

 

</td>

 

 

</tr>

 

 

<tr>

 

 

<td colspan="2">

 

 

<asp:Button ID="btnUpdate" Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Insert", "Update") %>'

 

 

runat="server" CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>'>

 

 

</asp:Button>&nbsp;

 

 

<asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button>

 

 

</td>

 

 

</tr>

 

 

</table>

 

 

</FormTemplate>

 

 

</EditFormSettings>

 

 

</MasterTableView>

 

 

</telerik:RadGrid>

 

 

<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:inspectors %>"

 

 

SelectCommand="getInspectorCertifications" SelectCommandType="StoredProcedure"

 

 

InsertCommand="insInspectorCertifications" InsertCommandType="StoredProcedure"

 

 

UpdateCommand="updInspectorCertifications" UpdateCommandType="StoredProcedure"

 

 

DeleteCommand="delInspectorCertification" DeleteCommandType="StoredProcedure">

 

 

<SelectParameters>

 

 

<asp:ControlParameter ControlID="Label1" Name="intInspectorID" PropertyName="Text" Type="Int32" />

 

 

</SelectParameters>

 

 

<InsertParameters>

 

 

<asp:ControlParameter ControlID="Label1" Name="intInspectorID" PropertyName="Text" Type="Int32" />

 

 

<asp:Parameter Name="intCertificationID" Type="Int32" />

 

 

<asp:Parameter Name="dtmDateExpires" Type="DateTime" />

 

 

</InsertParameters>

 

 

<UpdateParameters>

 

 

<asp:Parameter Name="intCertificationID" Type="Int32" />

 

 

<asp:Parameter Name="intInspectorID" Type="Int32" />

 

 

<asp:Parameter Name="dtmDateExpires" Type="dateTime" />

 

 

</UpdateParameters>

 

 

<DeleteParameters>

 

 

<asp:Parameter Name="intCertificationID" Type="Int32" />

 

 

<asp:Parameter Name="intInspectorID" Type="Int32" />

 

 

</DeleteParameters>

 

 

</asp:SqlDataSource>

 

</

 

telerik:RadPageView>

 

Tsvetoslav
Telerik team
 answered on 08 Jul 2011
3 answers
108 views

I've tested with and without a master page, with and without our css file, no difference.


If I specify a width on the grid and the mastertableview, the grid isn't centered on the screen.
If I remove the width on the grid it is centered.
If I set UseStaticHeaders="False" the command template is the same width as the mastertableview and centered.
If I set UseStaticHeaders="True" the command tamplate width is 100% of the screen and the mastertableview is centered.

We've never been able to use HorizontalAlign="Center" becuase we've never seen it work as expected, so we've been wrapping out grids in a <table> to center them. 

Is there something I'm missing?

<telerik:RadGrid ID="RadGrid1" HorizontalAlign="Center" runat="server" AllowPaging="false"
        AllowSorting="True" GridLines="None" BorderWidth="0" PageSize="5" BackColor="White"
        GroupingEnabled="False" CellSpacing="0" Width="750"
        <MasterTableView Name="RepMaster" HorizontalAlign="Center" Width="750" CommandItemDisplay="Top"
            BorderStyle="Solid" BorderWidth="1" BorderColor="Black" TableLayout="Fixed"
            <CommandItemTemplate
                <table border="0" style="width: 100%;"
                    <tr
                        <td align="left" style="width: 125px;"
                            <asp:Button CausesValidation="false" CommandName="InitInsert" runat="server" ID="btnAddNewRecord"
                                Text=" " title="Add new record" CssClass="rgAdd" /> 
                            <asp:LinkButton CausesValidation="false" ID="lnkbAddNewRecord" CommandName="InitInsert"
                                runat="server" CssClass="Link">Add new Record</asp:LinkButton
                        </td
                        <td align="center"
                        </td
                        <td align="right" style="width: 125px;"
                            <asp:Button CausesValidation="false" CommandName="RebindGrid" runat="server" ID="btnRefresh"
                                Text=" " title="Refresh" CssClass="rgRefresh" /> 
                            <asp:LinkButton CausesValidation="false" ID="lnkbRefresh" CommandName="RebindGrid"
                                runat="server" CssClass="Link">Refresh</asp:LinkButton
                        </td
                    </tr
                </table
            </CommandItemTemplate
            <CommandItemStyle BackColor="AliceBlue" Width="500" HorizontalAlign="Center" /> 
            <Columns
                <telerik:GridTemplateColumn UniqueName="RepMasterEdit" HeaderText="Edit"
                    <HeaderStyle HorizontalAlign="Center" /> 
                    <ItemStyle HorizontalAlign="Center" /> 
                    <ItemTemplate
                        <asp:ImageButton ID="imgbEdit" runat="server" CausesValidation="False" CommandName="Select"
                            CssClass="Link" ImageUrl="~/Images/btnEdit.gif" ToolTip="Edit" /> 
                    </ItemTemplate
                </telerik:GridTemplateColumn
            </Columns
        </MasterTableView
        <ClientSettings EnableRowHoverStyle="True"
            <Selecting AllowRowSelect="True" EnableDragToSelectRows="False"></Selecting
            <Scrolling AllowScroll="True" ScrollHeight="100%" UseStaticHeaders="true"></Scrolling
            <ClientEvents OnRowDblClick="RowDblClick" /> 
        </ClientSettings
    </telerik:RadGrid>

Private Sub RadGrid1_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource 
       Dim dt As New DataTable 
       'Add our columns 
       For i As Integer = 0 To 5 
           dt.Columns.Add("Field" + i.ToString, GetType(String)) 
       Next 
       Dim row As DataRow 
       For r As Integer = 0 To 50 
           row = dt.NewRow 
           For c As Integer = 0 To 5 
               row("Field" + c.ToString) = "Value " + r.ToString 
           Next 
           dt.Rows.Add(row) 
       Next 
       Me.RadGrid1.DataSource = dt 
   End Sub
Roger
Top achievements
Rank 1
 answered on 08 Jul 2011
1 answer
91 views
hello,

I have a radgrid with
 GridHyperLinkColumn gridHyperLinkColumn = new GridHyperLinkColumn();
gridHyperLinkColumn.AllowFiltering = true;
 gridHyperLinkColumn.CurrentFilterFunction = GridKnownFunction.Contains;
 gridHyperLinkColumn.ShowFilterIcon = false;
 gridHyperLinkColumn.AutoPostBackOnFilter = true;
But when i tested Filtering Function, the error occurred:
Sys$Enum$parse is not defined
parse()Teleri...98f28bc (line 8060)
b = "Contains"
a = undefined
filter()Teleri...98f28bc (line 7933)
h = "CaseId"
a = "216"
c = "Contains"
f = undefined
(?)()EditCa...seq/326 (line 2)
 
I dont know this error, please help me fix this.
thanks,
hung
Gabor
Top achievements
Rank 1
 answered on 08 Jul 2011
4 answers
147 views
I have some issue putting a datapager to a list box. Following below is my code
<telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="RadListBox1">
 </telerik:RadDataPager>
 
  <telerik:RadListBox ID="RadListBox1" runat="server" AutoPostBack="True"
                                                DataKeyField="EventLocation" DataSourceID="Listbox"
                                                DataTextField="EventLocation" DataValueField="EventLocation"
                                                DlisataKeyField="EventLocation" Skin="Black" allowpaging="true"
                                                style="z-index: 1; left: 1109px; top: 114px; position: absolute; height: 48px; width: 155px; text-align: center;"> <ButtonSettings TransferButtons="All" />
    </telerik:RadListBox>

When i run my aspx page, it doesnt show any paging
Iana Tsolova
Telerik team
 answered on 08 Jul 2011
2 answers
54 views
So the workaround for Upload & AJAX is to do a full postback when the appropriate button is clicked.  So I have this upload, the user browses for the file they're uploading and then click submit.  But instead of just doing a full postback, the webpage never fires any server-side events and returns a bunch of nonsense (see: attached image).

I feel like this is an AJAX response?  But it does do a full-postback it seems...and it doesn't seem to fire any of my events...
Calvin
Top achievements
Rank 1
 answered on 08 Jul 2011
4 answers
212 views

I'm trying to write a workaround for the bug in your RadTabStrip control that prevents tabs from being hidden and displayed on demand.

So instead of building the tabstrip with some tabs hidden, I now add only the tab items I want displayed initially, then use javascript to add further tab items later.

Here's a snippet of the js code...

var tabStrip = $find('myTabStrip');
 
var tab = new Telerik.Web.UI.RadTab();
tab.set_text('text');
tab.set_value('pseudo-id_because_ID_field_is_weirdly_not_supported');
 
var attributes = tab.get_attributes();
attributes.setAttribute("onclick", "alert('hello')");
 
tabStrip.get_tabs().insert(1, tab);

this runs ok and adds a tab to the page, but the attribute is never set, and when I look at the page source it has never been rendered. The items rendered using server side code with the same settings work fine.

Is there something else I should be doing, or is this another bug?

John
Top achievements
Rank 1
 answered on 08 Jul 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?