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

A bit more involved than the title indicates, though.  We've developed a search control (mark-up and some code below) which uses a RadAjaxPanel to set dates.  When the date changes, as part of the ajax postback, we go look up valid data for that date range and populate other search criteria.

All that's working great; the request I got was to handle the enter key being pressed and submit a search.  Of course, I'll want to apply it to whatever control has focus when an enter key is hit, but the textboxes in the date picker controls seems like an obvious place to start.

I've tried following this thread, but I'm not really getting it.  I'm not sure what event I should hook into to notice an enter key.  It doesn't seem like any client-side event is exposed which has to do with the text box of the date picker. 

The script I've cobbled together is invoked by a change when you use the actual date-picking UI part of the date picker control, so that's not quite what I'm looking for.  An error is raised saying that the object doesn't support this property or method, presumably when I'm trying to attach the event handler (I see the alert just before it).

Maybe I'm taking a completely wrong approach.  I'm pretty lost on the direction to go, and need a push.

Control mark-up:
---------------------------
<%@ Control Language="C#" AutoEventWireup="false" 
    CodeBehind="SearchFilterUI.ascx.cs" 
    Inherits="Com.Wolfgang.Amadeus.gTime.Web.SearchFilterUI" %>

<%@ Register TagPrefix="radC" Namespace="Telerik.WebControls" 
    Assembly="RadCalendar.Net2" %>

<%@ Register TagPrefix="radCB" Namespace="Telerik.WebControls" 
    Assembly="RadComboBox.Net2" %>

<%@ Register TagPrefix="radA" Namespace="Telerik.WebControls" 
    Assembly="RadAjax.Net2" %>

<div>

<radA:RadAjaxPanel ID="radAjaxPanel" runat="server" LoadingPanelID="ajaxLoadingPanel">

<div id="divSearchPeriod" runat="server" style="float: left;">

<asp:Label ID="lblByPayPeriod" runat="server" Font-Bold="true" Font-Size="Medium"

Text="Search by Pay Period:"></asp:Label>

<br />

<asp:Label ID="lblPayPeriod" runat="server" Text="Pay Period:" Width="75 px"></asp:Label>

<radCB:RadComboBox ID="rcbPayPeriod" runat="server" AutoPostBack="true" MarkFirstMatch="true"

OnSelectedIndexChanged="rcbPayPeriod_SelectedIndexChanged">

</radCB:RadComboBox>

<br />

<asp:Label ID="lblYear" runat="server" Text="Year:" Width="75 px"></asp:Label>

<radCB:RadComboBox ID="rcbYear" runat="server" AutoPostBack="true" MarkFirstMatch="true"

OnSelectedIndexChanged="rcbYear_SelectedIndexChanged">

</radCB:RadComboBox>

</div>

<div style="float: left; width: 343px;">

<asp:Label ID="lblByDates" runat="server" Font-Bold="true" Font-Size="Medium" Text="Search by Dates:"></asp:Label>

<br />

<asp:Label ID="lblStart" runat="server" Text="Start Date:" Width="70 px"></asp:Label>

<radC:RadDatePicker ID="rcStart" runat="server" AutoPostBack="true" EnableMultiSelect="false"

OnSelectedDateChanged="rcStart_SelectionChanged" ClientEvents-OnDateSelected="HandleEnter">

</radC:RadDatePicker>

<br />

<div style="float: right;">

</div>

<asp:Label ID="lblEnd" runat="server" Width="70 px" Text="End Date:"></asp:Label>

<radC:RadDatePicker ID="rcEnd" runat="server" AutoPostBack="true" EnableMultiSelect="false"

OnSelectedDateChanged="rcEnd_SelectionChanged">

</radC:RadDatePicker>

</div>

<div>

<br />

<br />

<br />

<br />

<br />

<asp:Panel ID="pnlUser" runat="server">

<asp:Label ID="lblUserName" runat="server" Text="User Name:" Width="110px"></asp:Label>

<radCB:RadComboBox ID="rcUser" runat="server" MarkFirstMatch="true">

</radCB:RadComboBox>

<asp:Label ID="lblNoUsers" runat="server" Text="No User Records in Selected Criteria"

Visible="false" />

</asp:Panel>

<asp:Panel ID="pnlClient" runat="server">

<asp:Label ID="lblClientName" runat="server" Text="Client Name:" Width="110px"></asp:Label>

<radCB:RadComboBox ID="rcClient" runat="server" MarkFirstMatch="true">

</radCB:RadComboBox>

<asp:Label ID="lblNoClients" runat="server" Text="No Client Records in Selected Criteria"

Visible="false" />

</asp:Panel>

<asp:Panel ID="pnlProject" runat="server">

<asp:Label ID="lblProjectName" runat="server" Text="Project Name:" Width="110px"></asp:Label>

<radCB:RadComboBox ID="rcProject" runat="server" MarkFirstMatch="true">

</radCB:RadComboBox>

<asp:Label ID="lblNoProjects" runat="server" Text="No Project Records in Selected Criteria"

Visible="false" />

</asp:Panel>

<asp:Panel ID="pnlUserRole" runat="server">

<asp:Label ID="lblUserRole" runat="server" Text="User Role:" Width="110px" />

<radCB:RadComboBox ID="rcUserRole" runat="server" MarkFirstMatch="true" />

</asp:Panel>

</div>

</radA:RadAjaxPanel>

<radA:AjaxLoadingPanel ID="ajaxLoadingPanel" runat="server" Transparency="25" BackColor="window">

<asp:Image ID="imgLoading" runat="server" ImageUrl="~/Loading.gif" AlternateText="Loading..." />

</radA:AjaxLoadingPanel>

</div>

<div>

<br />

<asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" Text="Search" />

</div>

<hr />

<div>

<asp:Label ID="lblSearchValue" runat="server"></asp:Label>

</div>
------------------------------

Here's how I tried to set up the javascript.  This is in the PreRender event handler of the search control:  (I figured once I got used to the setup, I could figure out how to actually invoke the btnSubmit's Submit then).

 

StringBuilder

 

js = new StringBuilder();

 

js.Append(

"<script type=\"text/javascript\">");

 

js.Append(

"\n");

 

js.Append(

"function HandleEnter(datePicker) {");

 

js.Append(

"\n\t");

 

js.Append(

"alert(\"here we are\");");

 

js.Append(

"\n\t");

 

js.Append(

"datePicker.AttachEventHandler(\"onkeydown\", function(eventArgs) {");

 

js.Append(

"\n\t\t");

 

js.Append(

"var key= eventArgs.keyCode;");

 

js.Append(

"\n\t\t");

 

js.Append(

"alert(\"key hit was: \" + key);");

 

js.Append(

"\n\t");

 

js.Append(

"}");

 

js.Append(

"\n\t");

 

js.Append(

");");

 

js.Append(

"\n\t");

 

js.Append(

"return false;");

 

js.Append(

"\n");

 

js.Append(

"}");

 

js.Append(

"\n");

 

js.Append(

"</script>");

 

 

this.Page.RegisterClientScriptBlock("keypress", js.ToString());

 

Yavor
Telerik team
 answered on 16 Oct 2008
2 answers
136 views
I am using the newest RadGrid and its export funationlity. THe data is being exported just fine, however, there is this annoying security warning message.

Question 1:

How do I get around this?

Question 2:

I am able to get around this by exporting to CSV. However. now, I am not able to add style attributes to certain cells. I have number cells whos content sometimes start with 0. These leading zeros are automatically removed unless I am able to add a style attribute to that cell. How do I fix that?

--tolga
Daniel
Telerik team
 answered on 16 Oct 2008
1 answer
56 views
I have a tabstrip with a MultiPage control.
On the first PageView I have an editor control with some text boxes and a couple of image buttons.
On the second PageView I have a couple of GridControls.
On the first grid I use the add new record command item. Only one column is editable.

When I hit the enter key after adding the data in the text box. The image button click event for the first image button on the first page view is called. The sender object is the image button but it is not visible when the enter key is hit. If the check image is clicked the item is added normally.

Since the ImageClickEventArgs x y coordinates are always zero when the event is erroniously called, I have a work around, but it is not apparent what would be causing this problem. 
Yavor
Telerik team
 answered on 16 Oct 2008
1 answer
164 views


Can you tell me how to fire the select button on page load?  I would like to have the file browse window appear right away when the page loads without the user having to click the select button.

I have attempted to add to the onclientadded handler with no luck.  I am trying to configure a simple one file upload within a window control.

Seems like a simple task not sure why I am having so much trouble with it.

Thanks,
Dave
Erjan Gavalji
Telerik team
 answered on 16 Oct 2008
5 answers
245 views
I keep getting this error. Using 2008 Q2 of radcontrols. Free version (still haven't bought) . This would not be such a big deal if it was not completely random, causing me to look like a friggin idiot every time it pops up and I have to say, " I have no idea why this is happening ". this occurance was not happening with the Q1 release. It is mysterious and confusing when testing. Can someone explain how to get rid of it please. If I drop all the ajax events, it still occur s wherever the dll is referenced.

error 1
Sys.WebForms.PageRequestManagerParserErrorException. The message received from the server could not be parsed. Common caused for this error are when the response is modified by calls to response.write(), Response filters, HttpModules, or server trace is enabled. Details: Error Parsing near '
<!Doctype HTML P' .

error 2
Sys.WebForms.PageRequestManagerParserErrorException. The message received from the server could not be parsed. Common caused for this error are when the response is modified by calls to response.write(), Response filters, HttpModules, or server trace is enabled.
Details: Error Parsing near 'Access to the path "'

Vlad
Telerik team
 answered on 16 Oct 2008
2 answers
164 views
How can control the look of a radpanelitem that is a separator?

This is how i create the radpanelitem:

Dim
rpiSeparator As New RadPanelItem
rpiSeparator.IsSeparator =
True
rpiSeparator.CssClass = "subMenuSeparator"
rpiSeparator.Text = "<hr />"
radPanel.items.add(rpiSeparator)

And this is my css:
.subMenuSeparator
{
 padding-top:5px;
 padding-left:0px;
 padding-right:0px;
 color:#000000;
}
   

It does not seem to have any effect.

 

Niclas
Top achievements
Rank 1
 answered on 16 Oct 2008
5 answers
146 views
Hi,

Following one of your tutorial, I was trying to edit/update record in the grid - the problem I am having is that for every editedItem returned blank..Following is the aspx and code behind file...Any help would be greatly appreciated..

Thanks.


<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="Test.aspx.vb" Inherits="ProjectTemplar.Test"
    title="Untitled Page" EnableViewState="true"%>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    <asp:Label ID="lblErrorMsg" runat="server" CssClass="errorFont"></asp:Label>
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false"
    OnNeedDataSource="RadGrid1_NeedDataSource"
    OnUpdateCommand="RadGrid1_UpdateCommand">
        <MasterTableView EditMode="InPlace">
        <Columns>
         <telerik:GridEditCommandColumn UpdateText="Update" EditText="Edit" CancelText="Cancel"></telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="BudgetExceptionID" Visible="TRUE" HEADERTEXT = "BudgetExceptionID" UniqueName="BudgetExceptionID" readonly="true"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ExceptionNotes" HeaderText="Exp. Notes" UniqueName="ExceptionNotes" ReadOnly="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Budget_DATETIME" HeaderText="Date &amp; Time">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="EffectivePeriod" HeaderText="Effective Period"
                    UniqueName="EffectivePeriod">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
</asp:Content>

--Code Behind ---

Imports Telerik.Web.UI
Partial Public Class Test
    Inherits System.Web.UI.Page

    Private ReadOnly Property GridSource() As DataTable
        Get
            Dim obj As Object = Me.ViewState("_gds")
            If (Not obj Is Nothing) Then
                Return CType(obj, DataTable)
            Else
                Dim table As DataTable = Nothing
                Try
                    Dim ds As DataSet
                    Dim batchManager As New DataBatchManager()
                    ds = batchManager.GetBudgetExceptionsByBatchID(34)
                    table = ds.Tables(0)
                    Me.ViewState("_gds") = table
                    Return table
                Catch ex As Exception
                    lblErrorMsg.Text = ex.Message
                End Try
                Return table
            End If
        End Get
    End Property

    Protected Sub RadGrid1_NeedDataSource(ByVal source As System.Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
        RadGrid1.DataSource = Me.GridSource
    End Sub
    Protected Sub RadGrid1_UpdateCommand(ByVal source As System.Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand
        Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
        Dim ordersTable As DataTable = Me.GridSource
        Dim id As String
        id = editedItem("Client").Text  '...returns blank..
        lblErrorMsg.Text = "Hello " + id.ToString()
    End Sub

Yavor
Telerik team
 answered on 16 Oct 2008
1 answer
130 views
Hi,
I am using GroupByFields in the grid. And I want to access the values in foreach GridItem in the code behind page. how can I access that?
 Following is the code.

Eg:

aspx page:

<

telerik:RadGrid ID="personalGridView" runat="server" AutoGenerateColumns="False"

 

 

AllowPaging="True" GridLines="None" AllowMultiRowSelection="true" ShowGroupPanel="False"

 

 

Skin="Office2007" OnPreRender="personalGridView_PreRender" OnPageIndexChanged="personalGridView_PageIndexChanged">

 

 

<FilterMenu EnableTheming="True">

 

 

<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

 

 

</FilterMenu>

 

 

<PagerStyle Mode="NumericPages" />

 

 

<MasterTableView>

 

 

<GroupByExpressions>

 

 

<telerik:GridGroupByExpression>

 

 

<SelectFields>

 

 

<telerik:GridGroupByField FieldAlias="Name" FieldName="Name" FormatString="" HeaderText="" />

 

 

</SelectFields>

 

 

<GroupByFields>

 

 

<telerik:GridGroupByField FieldName="Name" FieldAlias="Name" FormatString="" HeaderText="" />

 

 

</GroupByFields>

 

 

</telerik:GridGroupByExpression>

 

 

</GroupByExpressions>

 

 

<RowIndicatorColumn>

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</RowIndicatorColumn>

 

 

<ExpandCollapseColumn>

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</ExpandCollapseColumn>

 

 

<Columns>

 

 

<telerik:GridClientSelectColumn CommandName="Select">

 

 

</telerik:GridClientSelectColumn>

 

<

telerik:GridBoundColumn DataField="Amount" HeaderText="Amount">

 

 

 

 

</telerik:GridBoundColumn>

 

</Columns>

 

 

</MasterTableView>

 

 

<ClientSettings AllowDragToGroup="False">

 

 

<Selecting AllowRowSelect="True"></Selecting>

 

 

<Scrolling AllowScroll="True" UseStaticHeaders="True"></Scrolling>

 

 

<ClientMessages DragToGroupOrReorder="Drag to group" />

 

 

</ClientSettings>

 

 

</telerik:RadGrid>

 



CodeBehind:

foreach

(GridItem grdItem in personalGridView.SelectedItems)
{
}

 

Shinu
Top achievements
Rank 2
 answered on 16 Oct 2008
9 answers
214 views
I have two related grids... something like 
http://www.telerik.com/demos/aspnet/Grid/Examples/Programming/SelectedValue/DefaultCS.aspx

Now I would like to insert a new records in the second grid and when that happen I need to be able to get the selected customer's id from the first grid (Customer) in the second grid (Order) insert command event.

protected

void Order_InsertCommand(object source, GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
Hashtable newValues = new Hashtable();
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
// get the selected customerID from the first grid...

}

Thank you in advance

Yavor
Telerik team
 answered on 16 Oct 2008
3 answers
117 views
How can I populate the 

GridDropDownColumn in my codebehind (c#), ive found examples where the datasourceid is set in the aspx page like this

<telerik:GridDropDownColumn  
                                         UniqueName="DropDownListCategory" 
                                         ListTextField="Category" 
                                         ListValueField="Category" 
                                         DataSourceID="SqlDataSource2" 
                                         HeaderText="Category" 
                                         DataField="Category" 
                                         DropDownControlType="RadComboBox" 
                                         AllowSorting="true">  
                                        </telerik:GridDropDownColumn> 
 But the contents of the dropdown can change depending on a selection elsewhere on the page, so Id like to be able to set the datasource using c#
Shinu
Top achievements
Rank 2
 answered on 16 Oct 2008
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?