Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
92 views
I think I have figured out how to run ASP.Net Ajax with an ASPX view engine.  How do I use the ASP.Net Ajax with MVC3 Razor view engine.  I have not found any examples.  Any direction would be extremely helpful.
Sebastian
Telerik team
 answered on 28 Apr 2011
1 answer
58 views
i am using custom filtering in ragdrid...I need to add all the filter cell values in a filterlist object...how can i access all these filter column textboxes and also i need filter menu choices ...
Iana Tsolova
Telerik team
 answered on 28 Apr 2011
5 answers
366 views
Hi all, I have a grid which uses the advanced paging mode (next/prev, numeric buttons and page-size dropdown).
By default the page-size dropdown has options 10/20/50. We have a client request to change these options to 25/50/250.
How do I change these options?

I ideally don't want to have to write my own whole paging template, because then I would need to recreate also all the other functionality of the advanced pager... I just need to change the options in that dropdown.

Thanks in advance, CheerZ!

As an aside, is there a way i can make it so the user can type in 3-digits to the dropdown, instead of only 2? This should be enough to satisfy them then.
Sreedhar
Top achievements
Rank 1
 answered on 28 Apr 2011
1 answer
356 views
Hello
I'm having problem display correct date or time values in the Grid
The date column looks like 9/4/2011 12:00:00 πμ and the time column looks like 30/12/1899 2:18:39 μμ
I try everything i found in the forum like

Protected

 

Sub RadGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.SelectedIndexChanged

 

 

 

Dim colDates As GridBoundColumn

 

 

colDates = RadGrid1.Columns.FindByDataField(

"MyDate")

 

 

colDates.DataFormatString =

"{0:dd/MM/yyyy}"

 

 

Dim colTimes As GridBoundColumn

 

 

colTimes = RadGrid1.Columns.FindByDataField(

"MyTime")

 

 

colTimes.DataFormatString =

"{0:t}"

 

 

Me.RadGrid1.Rebind()

 

 

 

End Sub

but still i got the same format.
Any ideas?

 

O'Man
Top achievements
Rank 1
 answered on 28 Apr 2011
1 answer
111 views
Hi guys,

I have a page that displays a tree on the left and a grid on the right, the user is able to drag items from the tree and drop them into the grid.

I'm trying to implement the excel like grid functionality but it's not working
Can you please give any recommendation?
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Orders.aspx.vb" MasterPageFile="~/MasterPages/Backend.Master"
    Inherits="RestWeb.Orders" %>
  
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="Telerik" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" ID="content1" runat="server">
    <Telerik:RadScriptBlock runat="Server" ID="RadScriptBlock1">
  
        <script type="text/javascript">
            function OnClientClose_EDITOR(radWindow) {
                refreshGrid(args);
  
            }
            function refreshGrid(arg) {
                if (!arg) {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
                }
                else {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");
                }
            }
  
  
  
  
  
            /* <![CDATA[ */
            var gridId = "<%= orders.ClientID %>";
  
            //Handles the OnNodeDropping event of RadTreeView.
            function onNodeDropping(sender, args) {
                var dest = args.get_destNode();
  
                if (dest) {
                    //Handle dropping on a Node if required.
                }
                else {
                    dropOnHtmlElement(args);
                }
            }
  
            //Handles the case when a Node is dropped onto an HTML element.
            function dropOnHtmlElement(args) {
                if (droppedOnGrid(args))
                    return;
            }
  
            //Checks whether a Node is being dropped onto the RadGrid with ID: 'gridId'.
            //If not, the OnClientDropping event is canceled. 
            function droppedOnGrid(args) {
                var target = args.get_htmlElement();
  
                while (target) {
                    if (target.id == gridId) {
                        args.set_htmlElement(target);
  
                        return;
                    }
  
                    target = target.parentNode;
                }
  
                args.set_cancel(true);
            }
            /* ]]> */
        </script>
  
    </Telerik:RadScriptBlock>
    <Telerik:RadScriptBlock runat="server" ID="RadScriptBlock2">
  
        <script type="text/javascript">
            /* <![CDATA[ */
            var currentDraggedRow = null;
            var dataSetIndex = null;
            var visualClue = null;
            var currentNode = null;
  
            function onNodeMouseOver(sender, args) {
                //gets the node upon mousing over the node
                currentNode = args.get_node();
            }
  
            function onNodeMouseOut(sender, args) {
                //resets the currentNode value upon mousing out
                currentNode = null;
            }
  
            function onRowMouseOver(sender, args) {
                //gets the grid to be draggaed from
                grid = sender;
            }
  
            function onMouseDown(e, element, dataIndex) {
                //Store the currently dragged row (TR)
                currentDraggedRow = element;
                //Store the data key value of the dragged data grid row
                dataSetIndex = dataIndex;
  
                //Attach events to support rendering the visual clue
                $addHandler(document, "mousemove", mouseMove);
                $addHandler(document, "mouseup", mouseUp);
  
                //Prevent selection of text while dragging
  
                //Internet Explorer
                $addHandler(document, "selectstart", preventSelect);
  
                //Other browsers
                if (e.preventDefault)
                    e.preventDefault();
            }
  
            function preventSelect(e) {
                e.preventDefault();
            }
  
            function createVisualClue() {
                var div = document.createElement("div");
                div.style.position = "absolute";
                div.className = $get("<%= orders.ClientID %>").className;
                div.innerHTML = String.format("<table class='{0}'><tr>{1}</tr></table>",
                        $get("<%= orders.MasterTableView.ClientID %>").className,
                    currentDraggedRow.innerHTML);
  
                return div;
            }
  
            function mouseMove(e) {
                if (!visualClue) {
                    visualClue = createVisualClue();
                    document.body.insertBefore(visualClue, document.body.firstChild);
                }
  
                visualClue.style.left = e.clientX + 10 + "px";
                visualClue.style.top = e.clientY + 10 + "px";
            }
  
            function mouseUp(e) {
                if (visualClue) {
                    //Remove the visual clue
                    visualClue.parentNode.removeChild(visualClue);
                    visualClue = null;
                }
                //Detach the events supporting the visual clue
                $removeHandler(document, "mousemove", mouseMove);
                $removeHandler(document, "mouseup", mouseUp);
  
                //Detach the event preventing selection in Internet Explorer
                $removeHandler(document, "selectstart", preventSelect);
  
                if (currentNode && currentDraggedRow) {
                    //Store the value of the node on which the mouse is over
                    $get("<%=TreeNodeText.ClientID%>").value = currentNode.get_text();
  
                    //Store the data key value of the dragged data grid row
                    $get("<%= DataSetIndex.ClientID %>").value = dataSetIndex;
  
  
                    //Initiate AJAX request to update the page                              
                    var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
                    ajaxManager.ajaxRequest();
                }
            }
            /* ]]> */
        </script>
  
    </Telerik:RadScriptBlock>
    <asp:HiddenField runat="server" ID="DataSetIndex" />
    <asp:HiddenField runat="server" ID="TreeNodeText" />
    <asp:HiddenField ID="HiddenTableID" runat="server" />
    <asp:HiddenField ID="HiddenBarID" runat="server" />
    <Telerik:RadCodeBlock ID="RadCodeBlock2" runat="server">
  
        <script type="text/javascript">
            function CloseWnd() {
                GetRadWindow().close();
            }
            function GetRadWindow() {
                var oWindow = null;
                if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz az well)      
                return oWindow;
            }
        </script>
  
    </Telerik:RadCodeBlock>
    <Telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" DefaultLoadingPanelID="RadAjaxLoadingPanel2">
        <AjaxSettings>
            <Telerik:AjaxSetting AjaxControlID="tblGrid">
                <UpdatedControls>
                    <Telerik:AjaxUpdatedControl ControlID="orders" LoadingPanelID="RadAjaxLoadingPanel2" />
                </UpdatedControls>
            </Telerik:AjaxSetting>
        </AjaxSettings>
        <AjaxSettings>
            <Telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <Telerik:AjaxUpdatedControl ControlID="orders" LoadingPanelID="RadAjaxLoadingPanel2" />
                </UpdatedControls>
            </Telerik:AjaxSetting>
        </AjaxSettings>
    </Telerik:RadAjaxManager>
    <Telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel2" />
    <div id="tbldiv" runat="server" style="height: 100%">
        <Telerik:RadWindowManager ID="RadWindowManager2" runat="server" Visible="true" Behavior="Maximize,Close"
            Modal="true">
            <Windows>
                <Telerik:RadWindow Width="400" Height="250" VisibleStatusbar="false" ID="RadWindow1"
                    runat="server" VisibleOnPageLoad="false" />
            </Windows>
        </Telerik:RadWindowManager>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td height="20" valign="top">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td width="20" valign="top">
                                <img name="n2_1_1" src="../images/internalpanel/2_1_1.jpg" width="20" height="20"
                                    border="0" id="n2_1_1" alt="" />
                            </td>
                            <td valign="top" background="../images/internalpanel/2_1_bgd.jpg">
                                <div id="headtile" class="title">
                                    <asp:Label ID="Headtxt" runat="server" Text=""></asp:Label></div>
                            </td>
                            <td width="20" valign="top">
                                <img name="n2_1_2" src="../images/internalpanel/2_1_2.jpg" width="20" height="20"
                                    border="0" id="n2_1_2" alt="" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td valign="top">
                    <table border="0" cellpadding="0" cellspacing="0" class="tablePreview">
                        <tr>
                            <td width="20" valign="top" background="../images/internalpanel/2_left_bgd.jpg">
                                <img name="n2_left_bgd" src="../images/internalpanel/2_left_bgd.jpg" width="20" height="12"
                                    border="0" id="n2_left_bgd" alt="" />
                            </td>
                            <td height="50" valign="top">
                                <table border="0" cellpadding="3" cellspacing="0" style="width: 100%">
                                    <tr>
                                        <td class="title">
                                            Menu Items
                                            <Telerik:RadTreeView ID="RadTreeView1" runat="server" Height="300" Width="250" OnClientMouseOver="onNodeMouseOver"
                                                OnClientMouseOut="onNodeMouseOut" OnClientNodeDropping="onNodeDropping" EnableDragAndDrop="True"
                                                LoadingStatusPosition="BeforeNodeText" OnNodeDrop="RadTreeView1_NodeDrop">
                                            </Telerik:RadTreeView>
                                        </td>
                                        <td class="title">
                                            Orders
                                            <div id="tblGrid" runat="server">
                                                <Telerik:RadGrid ID="orders" AllowSorting="true" runat="server" Width="350px" OnNeedDataSource="orders_NeedDataSource"
                                                    OnItemCreated="orders_ItemCreated" Height="320px" AutoGenerateColumns="False" AllowMultiRowEdit="True">
  
                                                    <MasterTableView CommandItemDisplay="None" Width="100%" TableLayout="Fixed" EditMode="InPlace">
  
                                                        <Columns>
                                                        </Columns>
                                                    </MasterTableView>
                                                    <ClientSettings>
                                                        <ClientEvents OnRowMouseOver="onRowMouseOver" />
                                                        <Selecting EnableDragToSelectRows="false" />
                                                        <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="320px" />
                                                    </ClientSettings>
                                                    <ClientSettings EnableRowHoverStyle="true">
                                                        <Selecting AllowRowSelect="true" />
                                                    </ClientSettings>
                                                    <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric"></PagerStyle>
                                                </Telerik:RadGrid>
                                            </div>
                                        </td>
                                        <td valign="top">
                                            <table>
                                                <tr>
                                                    <td class="title">
                                                        Notes<br />
                                                        <Telerik:RadTextBox ID="txtNotes" MaxLength="250" Rows="10" Columns="30" TextMode="MultiLine"
                                                            runat="server">
                                                        </Telerik:RadTextBox>
                                                        <br />
                                                        <br />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="title" align="right">
                                                        Discount (in %): 
                                                        <Telerik:RadNumericTextBox ID="txtDiscount" Width="100" runat="server" /><br />
                                                        <asp:Button ID="btnDC" CommandName="Submit" runat="server" Text="Discount" />
                                                        <br />
                                                        <br />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="title" align="right">
                                                        Original Amount: 
                                                        <Telerik:RadNumericTextBox ID="txtortotal" ReadOnly="true" Width="100" runat="server" />
                                                        <br />
                                                        <br />
                                                        Total Amount: 
                                                        <Telerik:RadNumericTextBox ID="txtTotal" ReadOnly="true" Width="100" runat="server" />
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                        </td>
                                        <td>
                                               
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td width="20" valign="top" background="../images/internalpanel/2_right_bgd.jpg">
                                <img name="n2_right_bgd" src="../images/internalpanel/2_right_bgd.jpg" width="20"
                                    height="12" border="0" id="n2_right_bgd" alt="" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td height="20" valign="top">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td width="20" valign="top">
                                <img name="n2_2_1" src="../images/internalpanel/2_2_1.jpg" width="20" height="20"
                                    border="0" id="n2_2_1" alt="" />
                            </td>
                            <td valign="top" background="../images/internalpanel/2_2_bgd.jpg">
                                   
                            </td>
                            <td width="20" valign="top">
                                <img name="n2_2_2" src="../images/internalpanel/2_2_2.jpg" width="20" height="20"
                                    border="0" id="n2_2_2" alt="" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <table align="center" border="0" cellpadding="3" cellspacing="0" width="100%">
            <tr valign="middle">
                <td style="text-align: center">
                    <asp:HyperLink ID="printbill" runat="server">
                        <asp:ImageButton ID="Bill" CommandName="Bill" CausesValidation="true" ToolTip="Bill"
                            runat="server" ImageUrl="~/images/button_Bill.jpg" /></asp:HyperLink>
                    <asp:ImageButton ID="SaveButton" CommandName="Close" CausesValidation="true" ToolTip="Close Window"
                        runat="server" ImageUrl="~/images/button_ok.jpg" />
                    <asp:HyperLink ID="printorder" runat="server">
                        <asp:ImageButton ID="SendOrder" CommandName="Send" CausesValidation="true" ToolTip="Send Order"
                            runat="server" ImageUrl="~/images/button_send.jpg" /></asp:HyperLink>
                    <asp:ImageButton ID="Remove" CommandName="Remove" CausesValidation="true" ToolTip="Remove Order"
                        runat="server" ImageUrl="~/images/button_remove.jpg" />
                    <asp:ImageButton ID="Refresh" CommandName="Refresh" CausesValidation="true" ToolTip="Refresh Order"
                        Visible="false" runat="server" ImageUrl="~/images/button_refresh.jpg" />
                </td>
            </tr>
        </table>
    </div>
    <Telerik:RadInputManager ID="RadInputManager1" runat="server">
        <Telerik:NumericTextBoxSetting BehaviorID="NumericBehavior3" Type="Number" DecimalDigits="0">
            <TargetControls>
                <Telerik:TargetInput ControlID="txtTotal" />
            </TargetControls>
        </Telerik:NumericTextBoxSetting>
    </Telerik:RadInputManager>
</asp:Content>
<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="head">
</asp:Content>

and the code behind is the following:

Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports Telerik.Web.UI
Partial Public Class Orders
    Inherits System.Web.UI.Page
  
    Protected Sub Orders_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        Dim sTableID = Request.QueryString("TableID")
        Dim sBarID = Request.QueryString("BarID")
        txtDiscount.Value = 0
        txtortotal.Value = 0
  
        If Session("UserTypeID") = 4 Then
            Refresh.Visible = False
            Remove.Visible = False
        Else
            'txtDiscount.MaxValue = 100
        End If
  
        If sTableID Is Nothing Then
            If sBarID Is Nothing Then
                ScriptManager.RegisterStartupScript(Me, [GetType](), "closeWnd", "CloseWnd();", True)
            Else
                ViewState("Bar") = True
                HiddenBarID.Value = sBarID
                HiddenTableID.Value = 0
                Headtxt.Text = "BAR Number: " & sBarID
            End If
        Else
            ViewState("Table") = True
            HiddenBarID.Value = 0
            HiddenTableID.Value = sTableID
            Headtxt.Text = "TABLE Number: " & sTableID
            'get table name if exist
            Dim db As New RestData.RestDataContext()
            Dim sTableData = (From p In db.Tables _
                         Where p.number = sTableID _
                         And p.Type = "T" _
                             Select p).SingleOrDefault
  
            If sTableData IsNot Nothing Then
                Dim sTableName = sTableData.Owner
                Headtxt.Text = Headtxt.Text + "    -    " + "TABLE OWNER: " + sTableName
            End If
        End If
    End Sub
    Protected Sub SaveButton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles SaveButton.Click
  
        ScriptManager.RegisterStartupScript(Me, [GetType](), "closeWnd", "CloseWnd();", True)
    End Sub
    Friend Class SiteDataItem
        Private _text As String
        Private _id As Integer
        Private _parentId As Integer
        Public Property Text() As String
            Get
                Return _text
            End Get
            Set(ByVal value As String)
                _text = value
            End Set
        End Property
        Public Property ID() As Integer
            Get
                Return _id
            End Get
            Set(ByVal value As Integer)
                _id = value
            End Set
        End Property
        Public Property ParentID() As Integer
            Get
                Return _parentId
            End Get
            Set(ByVal value As Integer)
                _parentId = value
            End Set
        End Property
        Public Sub New(ByVal id As Integer, ByVal parentId As Integer, ByVal text As String)
            _id = id
            _parentId = parentId
            _text = text
        End Sub
    End Class
    Private Shared Sub BindToIEnumerable(ByVal treeView As RadTreeView)
        Dim siteData As New List(Of SiteDataItem)()
        Dim db As New RestData.RestDataContext
        Dim dd = db.usp_rr_admin_pu_Categories()
  
        For Each Category In dd
            Dim sCategoryID As Integer = Category.CategoryID
            Dim sCategory As String = Category.Category
            siteData.Add(New SiteDataItem(sCategoryID, 0, sCategory))
        Next
        Dim dd1 = db.usp_rr_admin_pu_Items()
        For Each Item In dd1
            Dim sItemID As Integer = Item.ItemID
            Dim sItemName As String = Item.ItemName
            Dim sParentID As Integer = Item.CategoryID
            siteData.Add(New SiteDataItem(sItemID, sParentID, sItemName))
        Next
         
        treeView.DataTextField = "Text"
        treeView.DataFieldID = "ID"
        treeView.DataFieldParentID = "ParentID"
        treeView.DataSource = siteData
        treeView.DataBind()
  
    End Sub
    Private ReadOnly Property DataSource() As DataTable
        Get
            Dim data As DataTable = DirectCast(Session("DataSource"), DataTable)
            txtTotal.Value = 0
            data = New DataTable()
            data.Columns.Add("Item Name")
            data.Columns.Add("Unit Price")
  
            Dim db As New RestData.RestDataContext
            Dim dd = db.usp_rr_admin_pu_Orders(HiddenBarID.Value, HiddenTableID.Value)
            For Each item In dd
  
                Dim sItemName As String = item.ItemName
                Dim sUnitPrice As Integer = item.UnitPrice
                Dim sReference As String = item.referenceID
                data.Rows.Add(New Object() {sItemName, sUnitPrice})
  
                If sReference Is Nothing Then
                    Dim number As String = Format("(0: D9)", (DateTime.Now.Ticks / 10) Mod 1000000000)
                    Session("Reference") = number
                Else
                    Session("Reference") = sReference
                End If
            Next
  
            Session("DataSource") = data
            Return data
        End Get
    End Property
    Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs)
        If Not Page.IsPostBack Then
            BindToIEnumerable(RadTreeView1)
            'RadTreeView1.ExpandAllNodes()
        End If
        MyBase.OnLoad(e)
    End Sub
    Protected Sub orders_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs)
        If TypeOf e.Item Is GridDataItem Then
            Dim dataItem As GridDataItem = TryCast(e.Item, GridDataItem)
            'Registers the onmousedown event to be fired upon selecting a grid's row and passes arguments to the event handler
            e.Item.Attributes("onmousedown") = String.Format("onMouseDown(event, this,{0})", dataItem.DataSetIndex)
            e.Item.Style("cursor") = "move"
        End If
    End Sub
    Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As AjaxRequestEventArgs)
        'This ajax request is fired upon dropping a grid's row onto a TreeNode
  
        'Finds the node, onto which the grid's row should be dropped, by text using the previously stored value of the "TreeNodeText" hidden field
        Dim destinationNode As RadTreeNode = RadTreeView1.FindNodeByText(TreeNodeText.Value)
        Dim sourceRow As DataRow = DataSource.Rows(Convert.ToInt32(DataSetIndex.Value))
  
        'Creates a new node using the respective grid's row information. The text of the TreeNode is set to be the value of the needed cell in the grid's datasource
        Dim sourceNode As New RadTreeNode(DirectCast(sourceRow("Column1"), String), DirectCast(sourceRow("Column2"), String))
  
        destinationNode.Nodes.Add(sourceNode)
        destinationNode.Expanded = True
  
        'Removes the row that has been dropped onto the treeview
        'DataSource.Rows.Remove(sourceRow)
  
        'Rebinds the grid to address the changes made to its datasource
        orders.Rebind()
  
        If e.Argument = "Rebind" Then
            orders.MasterTableView.SortExpressions.Clear()
            orders.MasterTableView.GroupByExpressions.Clear()
            orders.Rebind()
  
        ElseIf e.Argument = "RebindAndNavigate" Then
            orders.MasterTableView.SortExpressions.Clear()
            orders.MasterTableView.GroupByExpressions.Clear()
            orders.MasterTableView.CurrentPageIndex = orders.MasterTableView.PageCount - 1
            orders.Rebind()
  
        End If
  
  
    End Sub
    Protected Sub orders_NeedDataSource(ByVal source As Object, ByVal e As GridNeedDataSourceEventArgs)
        orders.DataSource = DataSource
        GetTotal()
    End Sub
    Protected Sub RadTreeView1_NodeDrop(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeDragDropEventArgs)
        'Handle when dropped on another Node.
        If e.SourceDragNode.Level <> 0 Then
            If e.DestDragNode IsNot Nothing Then
                'If e.SourceDragNode.Level <> "0" Then
            ElseIf e.HtmlElementID = orders.ClientID Then
                Dim dt As DataTable = DirectCast(Session("DataSource"), DataTable)
                For Each node As RadTreeNode In e.DraggedNodes
                    AddRowToGrid(dt, node)
                    'AddRowsToGrid(dt, node.Nodes)
                    'node.Remove()
                Next
            End If
            'End If
        End If
    End Sub
    Private Sub AddRowsToGrid(ByVal dt As DataTable, ByVal nodes As RadTreeNodeCollection)
        For Each node As RadTreeNode In nodes
            AddRowToGrid(dt, node)
            'AddRowsToGrid(dt, node.Nodes)
        Next
    End Sub
    Private Sub AddRowToGrid(ByVal dt As DataTable, ByVal node As RadTreeNode)
        Dim sText = node.Text
        Dim sItemID = node.Value
        Dim sUnitPrice = 0
        Dim sOrderID = 0
        Dim sBarID = HiddenBarID.Value
        Dim sTableID = HiddenTableID.Value
        Dim sNotes = txtNotes.Text
        Dim sOrderDate = Now
  
        Dim db As New RestData.RestDataContext()
        Dim sItemData = (From p In db.Items _
                     Where p.ItemName = sText _
                         Select p).Single
        If Not sItemData Is Nothing Then
            sText = sItemData.ItemName
            sItemID = sItemData.ItemID
            sUnitPrice = sItemData.UnitPrice
        End If
        db.Dispose()
  
        Dim values As String() = {sText, sUnitPrice, 0, sItemID}
        ' insert the new Order in the orders table
        Dim db2 As New RestData.RestDataContext()
        Dim p1 As New RestData.Order
        p1.ItemID = sItemID
        p1.BarID = sBarID
        p1.Notes = sNotes
        p1.OrderDate = Now
        p1.TableID = sTableID
  
        'db1.Orders.InsertOnSubmit(p1)
        db2.ExecuteCommand("INSERT INTO Orders (ItemID,TableID,BarID,OrderDate,Status,Notes,UserID) values ({0},{1},{2},{3},{4},{5},{6})", sItemID, sTableID, sBarID, sOrderDate, 1, sNotes, Session("UserID"))
        db2.SubmitChanges()
        db2.Dispose()
        db2 = Nothing
  
        'get last orderid
        Dim maxdb As New RestData.RestDataContext
        Dim maxorder = maxdb.usp_rr_admin_pu_GetMaxOrder()
        Dim maxOrderID = maxorder.Single.LastOrderID.Value
  
        'get reference number if exist for that table or bar, 
        'if not not we generate a new one
        Dim refdb As New RestData.RestDataContext
        Dim ref = refdb.usp_rr_admin_pu_Reference(HiddenBarID.Value, HiddenTableID.Value)
        For Each Order In ref
            If String.IsNullOrEmpty(Order.referenceID) Then
                Dim number As String = Format("(0: D9)", (DateTime.Now.Ticks / 10) Mod 1000000000)
                Session("Reference") = number
            Else
                Dim sReference As String = Order.referenceID
                Session("Reference") = sReference
            End If
        Next
  
        'update the last record with the reference number
        Dim db3 As New RestData.RestDataContext()
        Dim slastOrder = (From p In db3.Orders _
                     Where p.OrderID = maxOrderID _
                         Select p).Single
        slastOrder.ReferenceID = Session("Reference")
        db3.SubmitChanges()
        db3.Dispose()
        db3 = Nothing
  
        txtNotes.Text = ""
        orders.Rebind()
        GetTotal()
    End Sub
    Protected Sub Remove_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Remove.Click
        Dim sTableID = HiddenTableID.Value
        Dim sBarID = HiddenBarID.Value
        If sBarID <> 0 Then
            Dim sID = sBarID
            RadWindowManager2.Windows(0).NavigateUrl = "Remove.aspx?BarID=" & sID
        Else
            Dim sID = sTableID
            RadWindowManager2.Windows(0).NavigateUrl = "Remove.aspx?TableID=" & sID
        End If
  
        RadWindowManager2.Windows(0).VisibleOnPageLoad = True
        RadWindowManager2.Modal = True
        RadWindowManager2.Width = 850
        RadWindowManager2.Height = 550
        RadWindowManager2.Windows(0).Width = 850
        RadWindowManager2.Windows(0).Height = 550
        RadWindowManager2.KeepInScreenBounds = True
    End Sub
    Private Sub Orders_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        RadWindowManager2.Windows(0).VisibleOnPageLoad = False
        Dim sTableID = HiddenTableID.Value
        Dim sBarID = HiddenBarID.Value
        Dim sPath = ""
        Dim sPath1 = ""
  
        If sTableID IsNot Nothing And sTableID <> "0" Then
            Dim url = "Bill.aspx?TableID=" & sTableID & " &Discount=" & txtDiscount.Value & ""
            Dim url1 = "SendOrder.aspx?TableID=" & sTableID & " &Discount=" & txtDiscount.Value & ""
            sPath = url
            sPath1 = url1
        Else
            Dim url = "Bill.aspx?BarID=" & sBarID & " &Discount=" & txtDiscount.Value & ""
            Dim url1 = "SendOrder.aspx?BarID=" & sBarID & " &Discount=" & txtDiscount.Value & ""
            sPath = url
            sPath1 = url1
        End If
        OpenPopUp(printbill, sPath, "", 400, 550)
        OpenPopUp(printorder, sPath1, "", 400, 550)
  
        If Session("UserTypeID") = 4 Then
            txtDiscount.MaxValue = 10
        End If
        If Session("UserTypeID") = 1 Or Session("UserTypeID") = 2 Then
            txtDiscount.MaxValue = 100
        End If
        If Session("UserTypeID") = 3 Then
            txtDiscount.MaxValue = 37.5
        End If
    End Sub
    Public Shared Sub OpenPopUp(ByVal opener As System.Web.UI.WebControls.WebControl, ByVal PagePath As String, ByVal windowName As String, ByVal width As Integer, ByVal height As Integer)
        Dim clientScript As String
        Dim windowAttribs As String
        Dim tscroll = "Yes"
        windowAttribs = "width=" & width & "px," & _
                        "height=" & height & "px," & _
                        "ScrollBars=" & tscroll & "," & _
                        "left='+((screen.width -" & width & ") / 2)+'," & _
                        "top='+ (screen.height - " & height & ") / 2+'"
        clientScript = "window.open('" & PagePath & "','" & windowName & "','" & windowAttribs & "');return false;"
        opener.Attributes.Add("onClick", clientScript)
    End Sub
    Private Sub Refresh_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Refresh.Click
        orders.Rebind()
        GetTotal()
    End Sub
    Private Sub GetTotal()
        txtortotal.Value = 0
        Dim db As New RestData.RestDataContext
        Dim dd = db.usp_rr_admin_pu_Orders(HiddenBarID.Value, HiddenTableID.Value)
        For Each item In dd
            Dim sUnitPrice As Integer = item.UnitPrice
            txtortotal.Value = txtortotal.Value + sUnitPrice
        Next
        txtTotal.Value = txtortotal.Value - (txtortotal.Value * txtDiscount.Value / 100)
    End Sub
    Protected Sub btnDC_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnDC.Click
        'txtTotal.Value = txtortotal.Value - txtDiscount.Value
        txtTotal.Value = txtortotal.Value - (txtortotal.Value * txtDiscount.Value / 100)
    End Sub
      
  
    Private Sub Orders_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles orders.PreRender
        If Not IsPostBack Then
            For Each item As GridItem In orders.MasterTableView.Items
                If TypeOf item Is GridEditableItem Then
                    Dim editableItem As GridEditableItem = CType(item, GridDataItem)
                    editableItem.Edit = True
                End If
            Next
            orders.Rebind()
        End If
    End Sub
End Class
Radoslav
Telerik team
 answered on 28 Apr 2011
3 answers
168 views

I have a grid with three columns and I want user to enter their filter values and then click "Search Filter" button which is outside the grid.
Two columns have a textboxes for filter and the last column has a combobox with checkbox in it.
Everything works fine when the textbox columns are filtered. Problem occurs when the combobox with checkbox is selected.  it returns no data found. You  can see the image attached and also Client and Serverside codes.

Do let me know where am I going wrong...Any help will be appreciated.

ASPX

<telerik:RadGrid ID="rgPartnerPhone" runat="server" AllowFilteringByColumn="True"
   AllowPaging="True" AllowSorting="True" DataSourceID="dsPartnerPhone" GridLines="None"
Skin="Outlook" Width="100%" ShowGroupPanel="True" AutoGenerateColumns="False"
 PageSize="50" Height="570px" OnItemCreated="rgPartnerPhone_ItemCreated" OnPreRender="rgPartnerPhone_PreRender"
 ShowFooter="true"
 <MasterTableView DataSourceID="dsPartnerPhone" DataKeyNames="ProductID,  ProductName" 
PageSize="50" Width="100%" GroupLoadMode="Client" EnableNoRecordsTemplate="true"
ShowHeadersWhenNoRecords="true" AllowFilteringByColumn="true" AllowMultiColumnSorting="true"
EnableHeaderContextMenu="true"
<NoRecordsTemplate
<div style="color: Red; font-weight: bold"
No data found.</div
</NoRecordsTemplate
<Columns
 <telerik:GridNumericColumn DataField="ProductID" DataType="System.Int32" HeaderText="ProductID"
 SortExpression="ProductID" UniqueName="ProductID" ShowFilterIcon="false" AutoPostBackOnFilter="false"
CurrentFilterFunction="EqualTo" NumericType="Number" MaxLength="10" FilterControlWidth="60px"
HeaderStyle-Width="80px" ReadOnly="true" Groupable="false" AllowFiltering="true"
</telerik:GridNumericColumn
<telerik:GridTemplateColumn DataField="ProductName" HeaderText="ProductName" AutoPostBackOnFilter="false"
FilterDelay="4000" ShowFilterIcon="false" SortExpression="ProductName" UniqueName="ProductName"
CurrentFilterFunction="Contains" ItemStyle-Wrap="false" FilterControlWidth="260px"
HeaderStyle-Width="280px" Groupable="false" AllowFiltering="true"
<ItemTemplate
<asp:HyperLink ID="hlPName" runat="server" NavigateUrl='<%# Eval("CatalogPageLink")%>' 
      Target="_blank" Text='<%# Eval("ProductName")%>' ToolTip="Get Catalog Details"></asp:HyperLink
</ItemTemplate
       </telerik:GridTemplateColumn
<telerik:GridBoundColumn DataField="EquipmentType" HeaderText="EquipmentType" SortExpression="EquipmentType"
UniqueName="EquipmentType" ShowFilterIcon="false" FilterControlWidth="140px"
HeaderStyle-Width="160px" ItemStyle-Wrap="false" AllowFiltering="true"
                      <FilterTemplate
                         <telerik:RadComboBox ID="rcbEquip" runat="server" DataSourceID="dsGetEquipment"
AllowCustomText="true" DataTextField="EquipmentType" DataValueField="EquipmentTypeID"
Width="135px" AppendDataBoundItems="true" EmptyMessage="-- All Equipment --"
      HighlightTemplatedItems="true" AutoPostBack="true" TabIndex="1" Skin="Outlook"
OnClientDropDownOpening="OnClientDropDownOpening" OnClientDropDownClosing="OnClientDropDownClosing"
OnClientSelectedIndexChanging="OnClientSelectedIndexChanging" OnClientBlur="OnClientBlur"
OnClientDropDownClosed="onDropDownClosing"
<ItemTemplate
<div onclick="stopPropagation(event);"
<asp:CheckBox runat="server" ID="cbEquipment" 
Text='<%# DataBinder.Eval(Container, "Text") %>' /> 
</div
</ItemTemplate
</telerik:RadComboBox
<asp:SqlDataSource ID="dsEquipment" runat="server" ConnectionString="<%$ ConnectionStrings:connGait %>" 
  SelectCommand="dbo.CTsp_PPT_GetEquipmentType" SelectCommandType="StoredProcedure" /> 
  </FilterTemplate
</telerik:GridBoundColumn
  </Columns
</MasterTableView
<ClientSettings AllowColumnsReorder="True" AllowDragToGroup="True" ReorderColumnsOnClient="True"
EnableRowHoverStyle="true" EnablePostBackOnRowClick="false" AllowKeyboardNavigation="true"
ColumnsReorderMethod="Reorder"
<Resizing AllowColumnResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="True" /> 
<Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" FrozenColumnsCount="0"
</Scrolling
<ClientMessages /> 
</ClientSettings
<PagerStyle Mode="NextPrevNumericAndAdvanced" /> 
</telerik:RadGrid>

Serverside code
protected void btnFilters_Click(object sender, EventArgs e) 
   
       GridFilteringItem item = rgPartnerPhone.MasterTableView.GetItems(GridItemType.FilteringItem)[0] as GridFilteringItem; 
       //for ComboBox 
       string strEquip = string.Empty; 
       RadComboBox comborcbEquip = (RadComboBox)item.FindControl("rcbEquip"); 
       foreach (RadComboBoxItem ritem in comborcbEquip.Items) 
       
           CheckBox checkBox = (CheckBox)ritem.FindControl("cbEquipment"); 
           if (checkBox.Checked) 
           
               strEquip += ritem.Text + ","; 
           
       
       if (!string.IsNullOrEmpty(strEquip)) 
           strEquip = strEquip.Remove(strEquip.Length - 1); 
          
       string strProductID = (item["ProductID"].Controls[0] as RadNumericTextBox).Text; 
       string strProductName = (item["ProductName"].Controls[0] as TextBox).Text; 
       string strEquipType = strEquip; 
       string expression = ""; 
       
       if (strProductID != "") 
       
           if (expression != "") 
               expression += " AND "; 
           expression += "([ProductID]  = \'" + strProductID + "\')";   
       
       if (strProductName != "") 
       
           if (expression != "") 
               expression += " AND "; 
           expression += "([ProductName] LIKE \'%" + strProductName + "%\')"; 
       
       if (strEquipType != "") 
       
           string[] words = strEquipType.Split(','); 
           foreach (string citem in words) 
           
               if (expression != "") 
                   expression += " AND "; 
               expression += "([EquipmentType] LIKE \'%" + citem + "%\')"; 
           
       
       rgPartnerPhone.MasterTableView.GetColumnSafe("ProductID").CurrentFilterValue = strProductID; 
       rgPartnerPhone.MasterTableView.GetColumnSafe("ProductName").CurrentFilterValue = strProductName; 
      rgPartnerPhone.MasterTableView.GetColumnSafe("EquipmentType").CurrentFilterValue = strEquipType; 
       rgPartnerPhone.MasterTableView.FilterExpression = expression; 
       rgPartnerPhone.MasterTableView.Rebind(); 
   }

Thanks


Jessy
Mira
Telerik team
 answered on 28 Apr 2011
1 answer
44 views
Hi all,

Can any one give me an example or telerik documents about related comboboxes server side api? Thanks a lot.
Shinu
Top achievements
Rank 2
 answered on 28 Apr 2011
3 answers
110 views
asdf
Veronica
Telerik team
 answered on 28 Apr 2011
2 answers
205 views
Hi, I am facing a issue to find the ChildItem of the parent grid in ItemCreated event of Child grid after doing paging or filtering or sorting on parent grid.
Here is my code of OnNeedDataSource for Parent Grid :
public void GetInProcessData(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    EffortCertificationList effortCertifications = new EffortCertificationList();
    if (Session["IPEffortCertifications"] != null)
    {   effortCertifications = (EffortCertificationList)Session["IPEffortCertifications"];  }
    else
    {   effortCertifications.CurrEmployee = Session["currEmployee"].ToString();
        effortCertifications.Load("InProcess");
        Session["IPEffortCertifications"] = effortCertifications;
    }
   grdInProcess.DataSource = effortCertifications;
}

Here is my code of OnNeedDataSource for Child Grid which is in NestedViewTemplate :
protected void GetInProcesDetails(object source, GridNeedDataSourceEventArgs e)
{
                GridDataItem parentItem = ((source as RadGrid).NamingContainer as GridNestedViewItem).ParentItem as GridDataItem;
                string _employeeId = parentItem.GetDataKeyValue("Employee").ToString();
                Label lblBeginDate = (Label)parentItem.FindControl("lblIPStartDate");
                Label lblEndDate = (Label)parentItem.FindControl("lblIPEndDate");
                EffortCertificationList objeffortCertifications = new EffortCertificationList();
               if (Session["IPEffortCertifications"] != null)
               {
               objeffortCertifications = (EffortCertificationList)Session["IPEffortCertifications"];
               var effortDetails = from ec in objeffortCertifications
                                            where ec.Employee == _employeeId && ec.CertPeriodStartDate ==                                          Convert.ToDateTime(lblBeginDate.Text) && ec.CertPeriodEndDate == Convert.ToDateTime(lblEndDate.Text)
                                            select ec;
               EffortDetailList objEffortDetails = new EffortDetailList();
               foreach (var ed in effortDetails)
               {
                       objEffortDetails = ed.Details;
               }
               (source as RadGrid).AllowFilteringByColumn = false;
               (source as RadGrid).DataSource = objEffortDetails;
    }
 protected void grdInProcesDetails_ItemCreated(object sender, GridItemEventArgs e)
 {
       if (e.Item is GridDataItem)
       {
                GridDataItem item = (GridDataItem)e.Item;
                GridDataItem parentItem = ((sender as RadGrid).NamingContainer as GridNestedViewItem).ParentItem as GridDataItem;
                if (parentItem != null && parentItem.ChildItem !=null)
                {   string _employeeId = parentItem.GetDataKeyValue("Employee").ToString();
                    CheckBox chkIPReviewed = parentItem.ChildItem.FindControl("chkInProcessReviewed") as CheckBox;
                }
     }
}

Here in this event parentItem.ChildItem is null because of which i could not add attribute for calling javascript funcation for chkIPReviewed control. This is happening only after paging or sorting or filtering.
I am using client side function to expand or collapse for showing the Inner grid which is present in Nesstedviewtemplate.

Please provide me a solution.

Thanks in advance
MadhuSudhan
Top achievements
Rank 1
 answered on 28 Apr 2011
2 answers
114 views
Hi,

I'm trying to do "Grid / Self-referencing Hierarchy"
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/selfreferencing/defaultvb.aspx
But display "No child records to display." and repeat the herarquical data??

    Column1            Column2
v    Reg1name            value1
    No child records to display.
v    Reg2name            value2
    No child records to display.
v    Reg3name            value3
    v Reg31name         value31            <--herarquical data relation
        No child records to display.
    v Reg32name         value32     
        No child records to display.
v   Reg31name         value31            <-- Again!...
    No child records to display.
v   Reg32name         value32   
    No child records to display.
v    Reg4name            value4
    No child records to display.
....      

miguel
Top achievements
Rank 1
 answered on 27 Apr 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?