Telerik Forums
UI for ASP.NET AJAX Forum
0 answers
60 views
Solved. Been a long day. ;)

 
Danny
Top achievements
Rank 2
 asked on 04 Mar 2013
2 answers
189 views
Hi there,

I am using a RadDatePicker filter with the DisplayDateFormat="MM/dd/yyyy" and filter function=LessThanOrEqualTo. It seems the filter not returning the correct data, for example, if I set the RadDatePicker ="07/12/1996", the filter returning date prior to December 7th, 1996, while I am actually expecting date prior to July 12th, 1996.

Please see my following code (database is NorthWind), any help is greatly appreciated.

<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <%--Needed for JavaScript IntelliSense in VS2010--%>
                <%--For VS2008 replace RadScriptManager with ScriptManager--%>
                <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 Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <script type="text/javascript">
            //Put your JavaScript code here.
        </script>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default"></telerik:RadAjaxLoadingPanel>
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" CellSpacing="0"
            GridLines="None" Width="800px" AllowFilteringByColumn="true" EnableLinqExpressions="false" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource" ShowFooter="True">
            <MasterTableView AutoGenerateColumns="false" EditMode="InPlace" AllowFilteringByColumn="True"
            ShowFooter="True" TableLayout="Auto">
                <Columns>
                    <telerik:GridTemplateColumn DataField="Freight" HeaderText="Freight" SortExpression="Freight" AutoPostBackOnFilter="true" CurrentFilterFunction="GreaterThanOrEqualTo"
                        ShowFilterIcon="false">
                            <ItemTemplate>
                                <asp:LinkButton ID="lbl_freight" runat="server" Text='<%#Eval("Freight")%>' Visible="true"/>
                            </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn DataField="ShipName" HeaderText="Ship Name" SortExpression="ShipName" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                    ShowFilterIcon="false">
                        <ItemTemplate>
                            <asp:LinkButton ID="lbl_name" runat="server" Text='<%#Eval("ShipName")%>' Visible="true"/>
                        </ItemTemplate>
                   </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn DataField="OrderDate" UniqueName="OrderDate" HeaderText="Order Date" SortExpression="OrderDate">
                    <FilterTemplate>
                        <telerik:RadDatePicker ID="filterOrderDate" runat="server" Width="100%" ClientEvents-OnDateSelected="DateSelected"
                            DbSelectedDate='<%# SetOrderDate(Container) %>'><DateInput ID="DateInput1" runat="server"  DateFormat="MM/dd/yyyy" DisplayDateFormat="MM/dd/yyyy"></DateInput
                        </telerik:RadDatePicker
                        <telerik:RadScriptBlock ID="RadScriptBlock3" runat="server">
                            <script type="text/javascript">
                                function DateSelected(sender, args) {
                                    var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
  
                                    var date = FormatSelectedDate(sender);
  
                                    tableView.filter("OrderDate", date, "LessThanOrEqualTo");
                                }
                                function FormatSelectedDate(picker) {
                                    var date = picker.get_selectedDate();
                                    var dateInput = picker.get_dateInput();
                                    var formattedDate = dateInput.get_dateFormatInfo().FormatDate(date, dateInput.get_displayDateFormat());
  
                                    return formattedDate;
                                }
                            </script>
                        </telerik:RadScriptBlock>
                    </FilterTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lbl_duedate_gv" runat="server" Text='<%#Eval("OrderDate", "{0:MM/dd/yyyy}")%>' Visible="true"/>
                    </ItemTemplate>
               </telerik:GridTemplateColumn>
             </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </form>
</body>


cs code
public partial class RadGridFilterTest : System.Web.UI.Page
{
    protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
        LoadData();
    }
  
    private void LoadData()
    {
        RadGrid1.DataSource = GetDataTable("SELECT OrderID, OrderDate, Freight, ShipName, ShipCountry FROM Orders");
    }
  
    public DataTable GetDataTable(string query)
    {
        String ConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection conn = new SqlConnection(ConnString);
        SqlDataAdapter adapter = new SqlDataAdapter();
        adapter.SelectCommand = new SqlCommand(query, conn);
  
        DataTable myDataTable = new DataTable();
  
        conn.Open();
        try
        {
            adapter.Fill(myDataTable);
        }
        finally
        {
            conn.Close();
        }
  
        return myDataTable;
    }
  
    protected DateTime? SetOrderDate(GridItem item)
    {
        if (item.OwnerTableView.GetColumn("OrderDate").CurrentFilterValue == string.Empty)
        {
            return new DateTime?();
        }
        else
        {
            DateTime DT = new DateTime();
              
            DT = DateTime.ParseExact(item.OwnerTableView.GetColumn("OrderDate").CurrentFilterValue, "MM/dd/yyyy", null);
            //DT = DateTime.Parse(item.OwnerTableView.GetColumn("OrderDate").CurrentFilterValue);
            return DT;
        }
    }
}
Meng
Top achievements
Rank 1
 answered on 04 Mar 2013
3 answers
394 views
I want to call a javascript function when a radButton receives focus by tabbing onto the control.  Similarly, call a javascript function when radButton loses focus.  How can this be accomplished?
Mark
Top achievements
Rank 1
 answered on 04 Mar 2013
11 answers
603 views
I am working in C# for ASP.NET in Visual Studio version 2008.  I recently updated my environment to include the following:$0* 3.5 .NET Framework Service Pack.$0$0* 2008-08-20 release of the AJAX Control Toolkit.$0$0$0$0$0As soon as I made the upgrades listed above I started to receive the following message: 'ASP.NET Ajax client-side framework failed to load.'$0$0$0$0$0The error occurs due to the presence of the Telerik RadScriptManager control on a page.  If I replace that control with the standard AJAX ScriptManager control the error goes away.$0$0$0$0$0Any information you could provide would greatly be appreciated.$0$0$0$0$0Thank You,$0$0$0$0$0David Nowak.$0
Travis
Top achievements
Rank 1
 answered on 04 Mar 2013
3 answers
221 views
I'm using a RadGrid, and I'm able to show and hide columns using client-side script:

 

mygrid.get_masterTableView().hideColumn(i);

But, when I hide the column, it leaves a blank space where the column was located. Is it possible to have the remaining columns automatically resize and fill the empty space?

If this isn't possible, can I manually resize the remaining columns? I've tried the following script to set the hidden column width to zero, but it doesn't have any affect:

mygrid.get_masterTableView().resizeColumn(i, 0);

Sophie
Top achievements
Rank 2
 answered on 04 Mar 2013
9 answers
492 views
Is there a way to send tokens such as OAuth2 with the call to the ODataService?

I can see that there may be a way of injecting headers in the client-side event

OnRequesting but only if these are exposed in the args.set_Options object.



Thanks

Gary
Genady Sergeev
Telerik team
 answered on 04 Mar 2013
5 answers
587 views
I have a radgrid placed on a web form that uses PeterBlum's RequiredValidator and CustomValidator to validate some data on the page. 
I would like to validate the web form data before performing an Insert or Update on the grid.   
I am using radgrid's automatic insert and update actions.

The following approach succeeds in preventing the insert form from loading if the validation fails, but doesn't continue on to displaying the validation messages.
Any suggestions?
Protected Sub Grid_ItemCommand(source As Object, e As GridCommandEventArgs) Handles PreferredMediaEditableGrid.ItemCommand
 
    Select Case e.CommandName
 
      Case RadGrid.InitInsertCommandName
 
        PeterBlum.DES.Globals.Page.Validate()
        If Not PeterBlum.DES.Globals.Page.IsValid Then
 
          ' cancel automatic insert.
          e.Canceled = True
 
        End If
 
    End Select
 
  End Sub
Angel Petrov
Telerik team
 answered on 04 Mar 2013
1 answer
110 views
Hi
I have a reset button on a form with the following client-side code to clear the grid:

var view = $find('grd').get_masterTableView();
view.set_dataSource([]);
view.dataBind();


This works great but the NoMasterRecordsText is not shown on reset. This is set as follows in the MasterTable view:

ShowHeadersWhenNoRecords="true"
NoMasterRecordsText="No data available matching the supplied search criteria."

Perhaps somebody could shed some light on how to achieve this

Regards

Daniel Affleck
Daniel
Top achievements
Rank 1
 answered on 04 Mar 2013
4 answers
123 views
Are there any plans to make the rotator touch enabled?  

All of my customers expect touch enabled components, especially for this type of control.

Thanks, Marty
moegal
Top achievements
Rank 1
 answered on 04 Mar 2013
1 answer
44 views
Hi - i have a requirement very similar to what is achieved in http://demos.telerik.com/aspnet-ajax/listview/examples/itemdragdrop/defaultcs.aspx.

However, the main difference in my case is that the control to which i would drop my items (equivalent of Genre list shown in the right in the above link) is located in the master page and my list view is located in the content page.

When i drag the listview item onto the masterpage control, the destination is null. I used 
args.get_destinationItem()
in
OnClientDropped
event to get the destination item. If i drag the listview item onto any other control in the same page, the destination gets the proper value.

Is there a work-around to this problem. Am i missing something here?

Thanks.
Pavlina
Telerik team
 answered on 04 Mar 2013
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?