Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
534 views

hello

i am trying to implement a radgrid with filtering controls; one (or more, hopefully) column should be filtered using a checkbox list

here is the ascx code:

<telerik:RadGrid runat="server" AllowFilteringByColumn="True" FilterType="Combined" DataSourceID="SqlDataSource1"
    AllowPaging="True" PageSize="10" CellSpacing="0" GridLines="None" Skin="Bootstrap" HeaderStyle-Font-Bold="true"
     AutoGenerateColumns="False" ID="subFilesGrid" EnableViewState="true"
        OnPageIndexChanged="subFilesGrid_OnPageIndexChanged"
        onitemcommand="subFilesGrid_ItemCommand" OnFilterCheckListItemsRequested="subFilesGrid_FilterCheckListItemsRequested">
     
<MasterTableView DataKeyNames="nome">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
 
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
 
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
 
    <Columns>
        <telerik:GridButtonColumn Text="Download" CommandName="dloadFile" UniqueName="dcCol"></telerik:GridButtonColumn>
        <telerik:GridBoundColumn DataField="originalname" HeaderText="File Name" UniqueName="FileName" HeaderStyle-Width="150px" AllowFiltering="false">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="dinfo" HeaderText="Description" HeaderStyle-Width="180px" UniqueName="column" AllowFiltering="false">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="FileType" HeaderText="File Type" HeaderStyle-Width="150px" UniqueName="FileType" FilterCheckListEnableLoadOnDemand="true">
        </telerik:GridBoundColumn>
        <telerik:GridDateTimeColumn DataField="date" HeaderText="Submission Date" HeaderStyle-Width="180px"
            PickerType="DatePicker" FilterDateFormat="yyyy-MM-dd" DataFormatString="{0:yyyy-MM-dd HH:mm}">
        </telerik:GridDateTimeColumn>
        <telerik:GridTemplateColumn DataField="sName" HeaderText="Submitter" UniqueName="column2">
            <ItemTemplate>
                <%# SetSubmitter(Eval("sName"))%>
            </ItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn DataField="status" HeaderText="Status" UniqueName="column3">
            <ItemTemplate>
                <%# SetStatus(Eval("status"))%>
            </ItemTemplate>
        </telerik:GridTemplateColumn>
        
    </Columns>
 
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>
 
<FilterMenu EnableImageSprites="False">
<WebServiceSettings>
<ODataSettings InitialContainerName=""></ODataSettings>
</WebServiceSettings>
</FilterMenu>
 
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
<WebServiceSettings>
<ODataSettings InitialContainerName=""></ODataSettings>
</WebServiceSettings>
</HeaderContextMenu>
     
</telerik:RadGrid>

 and here is code-behind for filling the checkbox list

protected void subFilesGrid_FilterCheckListItemsRequested(object sender, GridFilterCheckListItemsRequestedEventArgs e)
        {
            string DataField = (e.Column as IGridDataColumn).GetActiveDataField();
            e.ListBox.Items.Clear();
            e.ListBox.AppendDataBoundItems = false;
            /*e.ListBox.DataSource = GetDataTable(DataField);
            e.ListBox.DataKeyField = DataField;
            e.ListBox.DataTextField = DataField;
            e.ListBox.DataValueField = DataField;
            e.ListBox.DataBind();*/
            string query = "SELECT type as FileType FROM [ICOS].[dbo].[FileType] where id_filetype!=20";
            // string.Format("SELECT type as FileType FROM [ICOS].[dbo].[FileType] where id_filetype!=20", field);
 
            SqlConnection cn = new SqlConnection(conn);
            cn.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = cn;
            cmd.CommandText = query;
            SqlDataReader rd = cmd.ExecuteReader();
            while (rd.Read())
            {
                e.ListBox.Items.Add(new RadListBoxItem(rd["FileType"].ToString()));
            }
            e.ListBox.DataTextField = DataField;
            e.ListBox.DataValueField = DataField;
            e.ListBox.DataBind();
            rd.Close();
            cn.Close();
            e.ListBox.ShowCheckAll = false;
             
        }

now, when loading the page, an unexpected item is displayed: ResourceNotFound#CheckListBox:CheckAll (you can see it here)

i have followed the steps showed in this page

Thanx in advance

Diego

Eyup
Telerik team
 answered on 22 May 2017
1 answer
187 views

Hello, can you convert this code into client side binding?

 

Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MyNamespaceGrid.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title id="HTMLTITLE">Default</title>

    <link href="/CSS/jquery-ui.min.css" type="text/css" rel="stylesheet" media="screen" />
    <link href="/CSS/jquery-ui.structure.min.css" type="text/css" rel="stylesheet" media="screen" />
    <link href="/CSS/jquery-ui.theme.min.css" type="text/css" rel="stylesheet" media="screen" />
    <script src="/CSS/jquery-1.4.2.min.js"></script>

    <style type="text/css">
        .HeaderGrey {
            background-color: #939da2 !important;
            background-image: none !important;
            color: White !important;
            border-right: 1px solid white !important;
            font-weight: bold !important;
            padding-top: 10px !important;
            padding-bottom: 10px !important;
        }

        .SubHeaderGrey {
            background-color: #A9B4B9 !important;
            background-image: none !important;
            color: White !important;
            border-right: 1px solid white !important;
            font-weight: bold !important;
        }

        .HeaderGreyNoBorder {
            background-color: #939da2 !important;
            background-image: none !important;
            color: White !important;
            font-weight: bold !important;
            padding-top: 10px !important;
            padding-bottom: 10px !important;
        }

        .SubHeaderGreyNoBorder {
            background-color: #A9B4B9 !important;
            background-image: none !important;
            color: White !important;
            font-weight: bold !important;
            border-right: 1px solid #A9B4B9 !important;
        }

        .BlueText {
            color: Blue !important;
        }

        .rgPager, .rgPager a {
            font-family: Verdana, Helvetica, Arial, sans-serif !important;
        }

        .rgWrap {
            font-family: Verdana, Helvetica, Arial, sans-serif !important;
        }

        div.RadGrid .rgRow td,
        div.RadGrid .rgAltRow td {
            padding: 5px;
        }

        .RadGrid_Default .rgMasterTable td.rgGroupCol, .RadGrid_Default .rgMasterTable td.rgExpandCol {
            border-color: white !important;
            background: white none !important;
        }

        .rgDetailTable {
            border: none !important;
        }

        .rgCollapse {
            background-image: url('/CSS/Images/ui-icons_469bdd_256x240minus.png') !important;
            background-position: 0px 0px !important;
        }

        .rgExpand {
            background-image: url('/CSS/Images/ui-icons_469bdd_256x240plus.png') !important;
            background-position: 0px 0px !important;
        }
    </style>
    <script type="text/javascript">
        function AddArrowIcons(sender, args) {
            var column = args.get_column();
            switch (column.get_uniqueName()) {
                case "ExpandColumn":
                    break;
                default:
                    column
                    .get_element()
                    .innerHTML +=
                    "&nbsp;&nbsp;<span class=\"ui-icon ui-icon-triangle-2-n-s\" style=\"float:right;-webkit-transform: scale(2);-ms-transform: scale(2);background-image: url(/CSS/images/ui-icons_ffffff_256x240.png)\"></span>"; //setting new HeaderText
                    break;
            }
        }
    </script>
</head>

<body>
    <form id="form1" runat="server">
        <div style="padding-left: 0px">
            <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>

            <table>
                <tr>
                    <td>Person Type:</td>
                    <td>
                        <asp:DropDownList runat="server" Width="175px" ID="ddlPersonType">
                            <asp:ListItem Selected="True" Value="Parent">Parent</asp:ListItem>
                            <asp:ListItem Value="SubAccount">Sub Account</asp:ListItem>
                            <asp:ListItem Value="Individual">Individual</asp:ListItem>
                        </asp:DropDownList></td>
                </tr>
                <tr>
                    <td>SIN Number - last 4 digits:</td>
                    <td>******<asp:TextBox runat="server" ID="txtSINNumber" MaxLength="4" Width="90px"></asp:TextBox></td>
                </tr>
                <tr>
                    <td>Name on Account:</td>
                    <td>
                        <asp:TextBox runat="server" ID="txtName" Width="175px"></asp:TextBox></td>
                </tr>
                <tr>
                    <td>Staus:</td>
                    <td>
                        <asp:DropDownList runat="server" Width="175px" ID="ddlStatus">
                            <asp:ListItem Selected="True" Value="All"> All </asp:ListItem>
                            <asp:ListItem Value="Normal">Normal</asp:ListItem>
                            <asp:ListItem Value="Expired">Expired</asp:ListItem>
                        </asp:DropDownList></td>
                </tr>

                <tr>
                    <td>
                        <asp:Button ID="btnFilter" Text="Filter" runat="server" OnClick="btnFilter_OnClick" class="btn110x21" />
                    </td>
                    <td>
                        <span class="ui-icon ui-icon-close" style="float: left; background-image: url(/CSS/images/ui-icons_222222_256x240.png)"></span>
                        <asp:LinkButton runat="server" ID="btnClearFilter" OnClick="btnClearFilter_OnClick" Text="Reset"></asp:LinkButton></td>
                </tr>
            </table>


            <div style="padding-top: 10px">
                <telerik:RadGrid ID="RadGrid2" runat="server" Width="1100px"
                    OnDetailTableDataBind="RadGrid1_DetailTableDataBind" AutoGenerateColumns="False" ShowStatusBar="False" PageSize="3"
                    AllowSorting="True" AllowMultiRowSelection="False" AllowPaging="True" GridLines="None" OnItemDataBound="RadGrid2_OnItemDataBound" AllowCustomPaging="False">
                    <PagerStyle Mode="NextPrevAndNumeric" Position="Bottom" PageSizeControlType="RadComboBox"></PagerStyle>
                    <MasterTableView HierarchyLoadMode="ServerBind" DataKeyNames="ParentAccountID,SinNumber,PersonType" Name="Parent" ExpandCollapseColumn-Display="false"
                        Font-Names="Verdana,Helvetica,Arial, sans-serif" Font-Size="12px">
                        <Columns>
                            <telerik:GridExpandColumn UniqueName="ExpandColumn" HeaderStyle-CssClass="HeaderGreyNoBorder"></telerik:GridExpandColumn>
                            <telerik:GridBoundColumn HeaderText="Person Type" HeaderButtonType="TextButton"
                                DataField="PersonType" UniqueName="PersonType" ItemStyle-HorizontalAlign="Left" HeaderStyle-CssClass="HeaderGrey">
                            </telerik:GridBoundColumn>

                            <telerik:GridTemplateColumn SortExpression="SinNumber" HeaderText="SIN Number" HeaderButtonType="TextButton"
                                UniqueName="SinNumber" ItemStyle-HorizontalAlign="Left" HeaderStyle-CssClass="HeaderGrey">
                                <ItemTemplate>
                                    <asp:HyperLink runat="server" ID="HyperLink2" CssClass="BlueText" Text='<%# Eval("SinNumber") %>' NavigateUrl="Demo.aspx">   
                                    </asp:HyperLink>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>

                            <telerik:GridBoundColumn SortExpression="ParentAccountID" HeaderText="ParentAccountID" HeaderButtonType="TextButton"
                                DataField="ParentAccountID" UniqueName="ParentAccountID" Visible="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="AccountHolderName" HeaderText="Name" HeaderButtonType="TextButton"
                                DataField="AccountHolderName" UniqueName="AccountHolderName" ItemStyle-HorizontalAlign="Left" HeaderStyle-CssClass="HeaderGrey">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="Status" HeaderText="Status" HeaderButtonType="TextButton"
                                DataField="Status" UniqueName="Status" ItemStyle-HorizontalAlign="Left" HeaderStyle-CssClass="HeaderGrey">
                            </telerik:GridBoundColumn>
                        </Columns>
                        <SortExpressions>
                            <telerik:GridSortExpression FieldName="AccountHolderName"></telerik:GridSortExpression>
                        </SortExpressions>

                        <DetailTables>
                            <telerik:GridTableView DataKeyNames="ParentAccountID,SinNumber,PersonType" Font-Names="Verdana,Helvetica,Arial, sans-serif" Font-Size="12px">
                                <Columns>
                                    <telerik:GridBoundColumn SortExpression="PersonType" HeaderText="Person Type" HeaderButtonType="TextButton"
                                        DataField="PersonType" UniqueName="PersonType" ItemStyle-HorizontalAlign="Left" HeaderStyle-CssClass="SubHeaderGrey" HeaderStyle-Width="160px">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridTemplateColumn SortExpression="SinNumber" HeaderText="SIN Number" HeaderButtonType="TextButton"
                                        UniqueName="SinNumber" ItemStyle-HorizontalAlign="Left" HeaderStyle-CssClass="SubHeaderGrey">
                                        <ItemTemplate>
                                            <asp:HyperLink runat="server" ID="HyperLink1" CssClass="BlueText" Text='<%# Eval("SinNumber") %>' NavigateUrl="Demo.aspx">   
                                            </asp:HyperLink>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridBoundColumn SortExpression="ParentAccountID" HeaderText="ParentAccountID" HeaderButtonType="TextButton"
                                        DataField="ParentAccountID" UniqueName="ParentAccountID" Visible="False">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn SortExpression="AccountHolderName" HeaderText="Name" HeaderButtonType="TextButton"
                                        DataField="AccountHolderName" UniqueName="AccountHolderName" ItemStyle-HorizontalAlign="Left" HeaderStyle-CssClass="SubHeaderGrey">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn SortExpression="Status" HeaderText="Status" HeaderButtonType="TextButton"
                                        DataField="Status" UniqueName="Status" ItemStyle-HorizontalAlign="Left" HeaderStyle-CssClass="SubHeaderGrey">
                                    </telerik:GridBoundColumn>
                                </Columns>
                                <SortExpressions>
                                    <telerik:GridSortExpression FieldName="AccountHolderName"></telerik:GridSortExpression>
                                </SortExpressions>
                            </telerik:GridTableView>
                        </DetailTables>
                    </MasterTableView>
                    <ClientSettings>
                        <ClientEvents OnColumnCreated="AddArrowIcons" />
                    </ClientSettings>
                </telerik:RadGrid>
            </div>
        </div>
    </form>
</body>
</html>

 

Default.aspx.cs:

 

using System;
using System.Collections.Generic;
using System.Linq;
using Telerik.Web.UI;

namespace MyNamespaceGrid
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var accounts = GetFitleredAccounts();
            RadGrid2.DataSource = accounts;
        }

        protected void RadGrid2_OnItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Parent")
            {
                GridDataItem item = (GridDataItem)e.Item;
                if (item.GetDataKeyValue("PersonType").ToString() == "Individual")
                {
                    (item["ExpandColumn"].Controls[0]).Visible = false;
                }
            }
        }

        protected void btnFilter_OnClick(object sender, EventArgs e)
        {
            RadGrid2.DataSource = GetFitleredAccounts();
            RadGrid2.Rebind();
        }

        protected void btnClearFilter_OnClick(object sender, EventArgs e)
        {
            txtSINNumber.Text = "";
            txtName.Text = "";
            ddlStatus.SelectedIndex = 0;
            ddlPersonType.SelectedIndex = 0;

            var accounts = GetAccounts();
            RadGrid2.DataSource = accounts;
            RadGrid2.Rebind();
        }

        protected void RadGrid1_DetailTableDataBind(object sende, GridDetailTableDataBindEventArgs e)
        {
            if (e.DetailTableView.ParentItem.DataItem == null)
            {
                int ParentAccountId = (int)e.DetailTableView.ParentItem.GetDataKeyValue("ParentAccountID");
                List<ParentAccount> row = (List<ParentAccount>)e.DetailTableView.DataSource;
                ParentAccount r = row.Where(z => z.ParentAccountID == ParentAccountId).FirstOrDefault();
                e.DetailTableView.DataSource = r.SubAccounts;
            }
            else
                e.DetailTableView.DataSource = ((ParentAccount)e.DetailTableView.ParentItem.DataItem).SubAccounts;
        }
        private List<ParentAccount> GetFitleredAccounts()
        {
            var accounts = GetAccounts();

            // is there a better way to initalize this
            var result = accounts.Where(s => s.ParentAccountID != null);

            #region Parent Filter

            if (ddlPersonType.Text == "Parent")
            {
                result = accounts.Where(s => s.PersonType == "Parent");

                if (!string.IsNullOrEmpty(txtSINNumber.Text))
                {
                    result = result.Where(s => s.SinNumber.EndsWith(txtSINNumber.Text));
                }
                if (!string.IsNullOrEmpty(txtName.Text))
                {
                    result = result.Where(s => s.AccountHolderName.ToUpper().Contains(txtName.Text.ToUpper()));
                }
                if (ddlStatus.SelectedIndex != 0)
                {
                    result = result.Where(s => s.Status == ddlStatus.Text);
                }
                return result.ToList();
            }

            #endregion

            #region Individual Filter

            if (ddlPersonType.Text == "Individual")
            {
                result = accounts.Where(s => s.PersonType == "Individual");

                if (!string.IsNullOrEmpty(txtSINNumber.Text))
                {
                    result = result.Where(s => s.SinNumber.EndsWith(txtSINNumber.Text));
                }
                if (!string.IsNullOrEmpty(txtName.Text))
                {
                    result = result.Where(s => s.AccountHolderName.ToUpper().Contains(txtName.Text.ToUpper()));
                }
                if (ddlStatus.SelectedIndex != 0)
                {
                    result = result.Where(s => s.Status == ddlStatus.Text);
                }
                return result.ToList();
            }

            #endregion

            #region Sub Account Filter

            if (ddlPersonType.Text == "SubAccount")
            {
                //inital dataset based on account type
                var resultList = accounts.Where(t => t.SubAccounts != null).ToList();

                if (!string.IsNullOrEmpty(txtSINNumber.Text))
                {

                    // Remove items for the parent table
                    for (int i = resultList.Count() - 1; i >= 0; i--)
                    {
                        bool foundMatch = false;

                        if (resultList[i].SubAccounts != null)
                        {
                            foreach (var sub in resultList[i].SubAccounts)
                            {
                                if (sub.SinNumber.EndsWith(txtSINNumber.Text))
                                {
                                    foundMatch = true;
                                }
                            }
                        }

                        if (foundMatch == false)
                            resultList.Remove(resultList[i]);
                    }

                    //filter child list
                    resultList.ForEach(
                        c => c.SubAccounts.RemoveAll(i => !i.SinNumber.EndsWith(txtSINNumber.Text)));

                    return resultList;
                }
                if (!string.IsNullOrEmpty(txtName.Text))
                {
                    // Remove items for the parent table
                    for (int i = resultList.Count() - 1; i >= 0; i--)
                    {
                        bool foundMatch = false;

                        if (resultList[i].SubAccounts != null)
                        {
                            foreach (var sub in resultList[i].SubAccounts)
                            {
                                if (sub.AccountHolderName.ToUpper().Contains(txtName.Text.ToUpper()))
                                {
                                    foundMatch = true;
                                }
                            }
                        }

                        if (foundMatch == false)
                            resultList.Remove(resultList[i]);
                    }

                    //filter child list
                    resultList.ForEach(
                        c =>
                            c.SubAccounts.RemoveAll(
                                i => !i.AccountHolderName.ToUpper().Contains(txtName.Text.ToUpper())));

                    return resultList;
                }
                if (ddlStatus.SelectedIndex != 0)
                {
                    // Remove items for the parent table
                    for (int i = resultList.Count() - 1; i >= 0; i--)
                    {
                        bool foundMatch = false;

                        if (resultList[i].SubAccounts != null)
                        {
                            foreach (var sub in resultList[i].SubAccounts)
                            {
                                if (sub.Status == ddlStatus.Text)
                                {
                                    foundMatch = true;
                                }
                            }
                        }

                        if (foundMatch == false)
                            resultList.Remove(resultList[i]);
                    }

                    //filter child list
                    resultList.ForEach(c => c.SubAccounts.RemoveAll(i => i.Status != ddlStatus.Text));

                    return resultList;
                }
            }

            #endregion

            return accounts;

        }

        private List<ParentAccount> GetAccounts()
        {

            #region Hardcoded data

            List<ParentAccount> accounts = new List<ParentAccount>
            {
                new ParentAccount
                {
                    ParentAccountID = 2,
                    PersonType = "Individual",
                    AccountHolderName = "Grace Nix",
                    SinNumber = "7501",
                    Status = "Normal"
                },

                new ParentAccount
                {
                    ParentAccountID = 3,
                    PersonType = "Parent",
                    AccountHolderName = "Andrew Mill",
                    SinNumber = "7535",
                    Status = "Normal",
                    SubAccounts = new List<SubAccount>
                    {
                        new SubAccount
                        {
                            ParentAccountID = 3,
                            SubAccountID = 12,
                            PersonType = "Sub Account",
                            AccountHolderName = "Joe Danny",
                            SinNumber = "7600",
                            Status = "Normal"
                        },
                        new SubAccount
                        {
                            ParentAccountID = 3,
                            SubAccountID = 12,
                            PersonType = "Sub Account",
                            AccountHolderName = "Chris Robminson",
                            SinNumber = "7626",
                            Status = "Normal"
                        }
                        ,new SubAccount
                        {
                            ParentAccountID = 3,
                            SubAccountID = 12,
                            PersonType = "Sub Account",
                            AccountHolderName = "Alex Fisher",
                            SinNumber = "7600",
                            Status = "Normal"
                        },
                        new SubAccount
                        {
                            ParentAccountID = 3,
                            SubAccountID = 12,
                            PersonType = "Sub Account",
                            AccountHolderName = "Mark Reece",
                            SinNumber = "7626",
                            Status = "Normal"
                        }
                        ,
                        new SubAccount
                        {
                            ParentAccountID = 3,
                            SubAccountID = 12,
                            PersonType = "Sub Account",
                            AccountHolderName = "Dale Morison",
                            SinNumber = "7600",
                            Status = "Expired"
                        },
                        new SubAccount
                        {
                            ParentAccountID = 3,
                            SubAccountID = 12,
                            PersonType = "Sub Account",
                            AccountHolderName = "Rob Mason",
                            SinNumber = "7626",
                            Status = "Normal"
                        }
                    }
                }

                ,
                new ParentAccount
                {
                    ParentAccountID = 4,
                    PersonType = "Parent",
                    AccountHolderName = "Wes Allman",
                    SinNumber = "7501",
                    Status = "Normal",
                    SubAccounts = new List<SubAccount>
                    {
                        new SubAccount
                        {
                            ParentAccountID = 4,
                            SubAccountID = 12,
                            PersonType = "Sub Account",
                            AccountHolderName = "Gin Un",
                            SinNumber = "2222",
                            Status = "Normal"
                        },
                        new SubAccount
                        {
                            ParentAccountID = 4,
                            SubAccountID = 12,
                            PersonType = "Sub Account",
                            AccountHolderName = "Mick Colt",
                            SinNumber = "3333",
                            Status = "Expired"
                        }
                    }
                },

                new ParentAccount
                {
                    ParentAccountID = 6,
                    PersonType = "Parent",
                    AccountHolderName = "Tracy Anderson",
                    SinNumber = "7535",
                    Status = "Expired",
                    SubAccounts = new List<SubAccount>
                    {
                        new SubAccount
                        {
                            ParentAccountID = 6,
                            SubAccountID = 12,
                            PersonType = "Sub Account",
                            AccountHolderName = "Jon Wex",
                            SinNumber = "7600",
                            Status = "Expired"
                        },
                        new SubAccount
                        {
                            ParentAccountID = 6,
                            SubAccountID = 12,
                            PersonType = "Sub Account",
                            AccountHolderName = "Ruan Juan",
                            SinNumber = "7626",
                            Status = "Normal"
                        }
                    }
                },
                new ParentAccount
                {
                    ParentAccountID = 18,
                    PersonType = "Parent",
                    AccountHolderName = "Marie Wilson",
                    SinNumber = "3333",
                    Status = "Normal",
                    SubAccounts = new List<SubAccount>
                    {
                        new SubAccount
                        {
                            ParentAccountID = 18,
                            SubAccountID = 12,
                            PersonType = "Sub Account",
                            AccountHolderName = "Ron Ottan",
                            SinNumber = "7600",
                            Status = "Normal"
                        },
                        new SubAccount
                        {
                            ParentAccountID = 18,
                            SubAccountID = 12,
                            PersonType = "Sub Account",
                            AccountHolderName = "Will Naw",
                            SinNumber = "7626",
                            Status = "Normal"
                        }
                    }
                },
                new ParentAccount
                {
                    ParentAccountID = 19,
                    PersonType = "Parent",
                    AccountHolderName = "Dan Can",
                    SinNumber = "7535",
                    Status = "Normal",
                    SubAccounts = new List<SubAccount>
                    {
                        new SubAccount
                        {
                            ParentAccountID = 19,
                            SubAccountID = 12,
                            PersonType = "Sub Account",
                            AccountHolderName = "Esther Cran",
                            SinNumber = "3333",
                            Status = "Normal"
                        },
                        new SubAccount
                        {
                            ParentAccountID = 19,
                            SubAccountID = 12,
                            PersonType = "Sub Account",
                            AccountHolderName = "Paul Max",
                            SinNumber = "7626",
                            Status = "Normal"
                        }
                    }
                }
            };

            #endregion
            return accounts;
        }
    }

    public class ParentAccount
    {
        public int ParentAccountID { get; set; }
        public string PersonType { get; set; }
        public string SinNumber { get; set; }
        public string AccountHolderName { get; set; }
        public string Status { get; set; }

        public List<SubAccount> SubAccounts;
    }

    public class SubAccount
    {
        public int SubAccountID { get; set; }
        public int ParentAccountID { get; set; }
        public string PersonType { get; set; }
        public string SinNumber { get; set; }
        public string AccountHolderName { get; set; }
        public string Status { get; set; }

    }

}

Eyup
Telerik team
 answered on 22 May 2017
1 answer
660 views

Using the code mentioned in your article here - http://docs.telerik.com/devtools/aspnet-ajax/controls/spreadsheet/client-side-programming/events/onclientchange

 

We have a simple aspx page with RadSpreadsheet object on it, along with the code mentioned in above article for onClientChange, but that never gets hit.

What are we missing?

Vessy
Telerik team
 answered on 22 May 2017
1 answer
116 views

Support,

OnClientEnded, i used this event to trigger a java script at the end of a Play.

 

Is there any way i could run a script at the end of video play.

If you have any example please share.

Thanks

 

Eyup
Telerik team
 answered on 22 May 2017
1 answer
238 views

Hi,

I will try to explain the scenario the best way possible. I hope you can help me.

I have a page which has one user control with filters. Those filters are displayed dynamically with some information we have stored in the database. Depending on what you select in those filters, the page has to load dynamically one or more user controls with the results (each one will have a radgrid). For example, if in the filter "department", you select the departments A, B, C and D, after clicking in "Submit", we have to create four different result user controls because each department has different columns to display. So having one non-dynamic user control with a radgrid is not an option. Also I have tried having a non-dynamic user control, but creating radgrids dynamically and the results wasn't good. I have to say that I have this scenario fully working with asp.net gridviews, but I need to have better performance and more functionality. This is the main reason of using this telerik control.

I don't have any problem loading the data, but with the radgrid events (sorting, paging), the whole page does a postback and the radgrids are not there.

I'm using advanced server side binding, but I have tried simple binding too with the same result.

 

- The relevant code in the page is. This is called when you select the filters and you click in "Submit":

01.public void GetReports(List<ReportModel> reports)
02.{
03.    int count = 1;
04.    foreach (ReportModel report in reports)
05.    {
06.        DataSet ds = ReportData.GetReportData(report); // If there's no data, this function always return a dataset with one datable informing that there's no data available
07.    foreach (DataTable dt in ds.Tables)
08.        {
09.            ReportResults control = this.LoadControl("~/Reports/Controls/ReportResults.ascx") as ReportResults;
10.            control.ID = string.Format("reportResults{0}", count);
11.            control.Data = data;
12.            this.pnlResults.Controls.Add(control);
13.        }
14.    }
15.}

 

- The client side code in the user control:

<telerik:RadAjaxPanel id="pnlReport" runat="server" cssclass="panel-body nopadding" style="width: 100%; overflow: auto;">
    <telerik:radgrid id="radgrid" runat="server" cssclass="table table-striped table-hover" borderstyle="Solid"
        autogeneratecolumns="true" allowpaging="true" allowsorting="true" rendermode="Lightweight" skin="Bootstrap" onneeddatasource="radgrid_NeedDataSource">
        <pagerstyle mode="NextPrevNumericAndAdvanced" />
    </telerik:radgrid>
</telerik:RadAjaxPanel>

 

- The server side code in the user control:    

01.public DataTable Data
02.{
03.      get
04.      {
05.            return (DataTable)this.ViewState["Data"];
06.      }
07.      set
08.      {
09.             this.ViewState["Data"] = value;
10.      }
11.}
12. 
13. 
14.protected void radgrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
15.{
16.       (sender as RadGrid).DataSource = this.Data; //I have already debugged the code and I have seen that this property has data and it's displayed when I click in "Submit"
17.}

 

Thank you for your help.
Xabier
Top achievements
Rank 1
 answered on 19 May 2017
0 answers
102 views

in myDbSchedulerProvider (through webservice) > GetAppointments

I can set apt.Start , apt.Description , apt.ID , apt.Subject and those carry forward to the page.

apt.Subject = dr("Title")
apt.Start = DateTime.SpecifyKind(StartTime, DateTimeKind.Utc)
apt.Description = dr("Content")
 
apt.CssClass = "mapping" & dr("Category").replace(";", "")
apt.ForeColor = Drawing.Color.Beige
apt.BackColor = Drawing.Color.Coral
apt.Attributes("class") = "mapping" & dr("Category").replace(";", "")

but if I set any of these values, they do not carry forward.
apt.CssClass , apt.ForeColor , apt.BackColor , apt.Attributes("class")

in the click appointment javascript event I alert these values and they are blank or null
but as I said, if I alert the other ones they give correct values.

function OnClientAppointmentClick(sender, args) {
alert(apt.get_start().format("MM/dd/yyyy HH:mm")) ; //<-- good value
alert(apt.get_description()); //<-- good value
 
alert(apt.get_cssClass()); //<-- blank value
alert(apt.get_backColor()); //<-- null value
 
etc etc
Doug
Top achievements
Rank 1
 asked on 19 May 2017
0 answers
138 views
When i am setting text and saving it, sometimes is losing spacing between words. If i go and set it up correctly and save it just reverts back to the document without spacing. It doesn’t do it for every space just certain sections. I have an image attached. Could you please advice on a fix?
Evgheni
Top achievements
Rank 1
 asked on 19 May 2017
5 answers
116 views
Hello,

We have noticed that in Q3 2010 clicking on a RadToolbarButton image does not navigate to the page specified RadToolbarButton NavigateUrl. Clicking on the text or area around the text works fine. (Clicking on an image was working in Q2 2008)

Here's my code:
<style type="text/css">
     div.RadToolBarDropDown .rtbWrap
     {
         line-height: 52px;
         padding-left: 57px;
     }
        
     div.RadToolBarDropDown .rtbItemHovered,
     div.RadToolBarDropDown .rtbItemFocused, 
     div.RadToolBarDropDown .rtbItemHovered .rtbWrap,
     div.RadToolBarDropDown .rtbItemFocused .rtbWrap
     {
         background-image: none;
         background-color: #8E8E8E;
     }
 </style>
   
 <telerik:RadToolBar ID="radToolBarMenu" runat="server" Orientation="Vertical">
     <Items>
         <telerik:RadToolBarDropDown runat="server" ImageUrl="~/Images/NewReceipt.jpg" 
             Text="Receipt">
             <Buttons>
                 <telerik:RadToolBarButton runat="server" 
                     ImageUrl="~/Images/ReceiptInternal.jpg" NavigateUrl="~/Internal.aspx" 
                     Text="Internal">
                 </telerik:RadToolBarButton>
                 <telerik:RadToolBarButton runat="server" 
                     ImageUrl="~/Images/ReceiptExternal.jpg" NavigateUrl="~/External.aspx" 
                     Text="External">
                 </telerik:RadToolBarButton>
             </Buttons>
         </telerik:RadToolBarDropDown>
     </Items>
 </telerik:RadToolBar>

Is it possible to navigate when clicking on the image?

Thanks,

Matt
Rumen
Telerik team
 answered on 19 May 2017
1 answer
185 views

Hello there,

I have a requirement to validate that an expiration date is later than a hire date. Both dates are populated in a GridBoundColumn in a RadGrid. Bellow is the code for the two columns in my aspx page:

<telerik:GridBoundColumn ColumnEditorID="DateEditor" DataField="Hired" Visible="true" ReadOnly="false" HeaderText="Hired" UniqueName="gcHired" DataType="System.String" FilterControlAltText="Filter gcHired column"></telerik:GridBoundColumn>
                                                <telerik:GridDateTimeColumn ColumnEditorID="DateEditor" MinDate="2017-01-01" MaxDate="2030-12-31" DataFormatString="{0:MM/dd/yyyy}" DataField="Expires" HeaderText="Expires" UniqueName="gcExpires" FilterControlAltText="Filter column column" AllowFiltering="False" AllowSorting="False" DataType="System.DateTime" ReadOnly="false">
                                                    <HeaderStyle Width="100px"></HeaderStyle>
                                                </telerik:GridDateTimeColumn>

 

I am wondering if there is a straight forward way to achieve this. Thanks in advance!

Marin Bratanov
Telerik team
 answered on 19 May 2017
11 answers
1.4K+ views
Hello, I am trying to use clientside events to hide the edit and delete columns as well as the filter row when an export is being performed on the radgrid, then show those items again after the export.  I've managed to hide them before the export and the export looks fine other than a short empty row still being where the filter row was for pdf and word (hideFilterItem does not seem to hide it from export; excel is fine though since I'm using ExcelML).  

The part I'm having difficulty with is getting them to show up again.  I've tried attaching a few client side events (such as OnTableCreated) to this function, but everything I've tried either causes errors or does nothing:

UnhideGridEditAndDeleteColumnsAndFilterRow = function (sender, eventArgs) {
 
 // I'm using js in a separate file so I can't use radcodeblock to get ClientID
    var gridName = sender.EventTarget.toString();
 
    gridName = gridName.substring(0, gridName.indexOf("$ctl00"));
 
    var masterTableView = $find(gridName).get_masterTableView();
 
    if (masterTableView.getColumnByUniqueName("EditCommandColumn") != null && masterTableView.getColumnByUniqueName("DeleteCommandColumn") != null) {
      masterTableView.showFilterItem();
      masterTableView.showColumn(masterTableView.getColumnByUniqueName("EditCommandColumn").get_element().cellIndex);
      masterTableView.showColumn(masterTableView.getColumnByUniqueName("DeleteCommandColumn").get_element().cellIndex);
    }
 
 
  };


Is there a proper way to do this that I haven't found?
Neha
Top achievements
Rank 1
 answered on 19 May 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?