drupal stats

Telerik

Remove Borders from RadMenu (Telerik)

Add the following CSS styles to remove borders in RadMenu

<style type="text/css"> 

/* Rootmenu items */ 

.RadMenu .rmRootGroup  

{ 

    border: none !important; 

    

} 

/* Submenu items */ 

.RadMenu .rmGroup 

{ 

     border: none !important; 

} 

</style>

Keep Selected Rows when Paging in RadGrid (Telerik)

Keep Selected Rows when Paging in RadGrid Telerik thumb Keep Selected Rows when Paging in RadGrid (Telerik)

We use Session and ArrayList to save the selected rows

public ArrayList arrayList = new ArrayList();

 

Convert "Session" to "ArrayList" for easy manipulation

protected void SessionToArrayList()

{

    if (Session["selectedRows"] != null)

    {

        arrayList = (ArrayList)Session["selectedRows"];

    }

}

 

Get selected rows when Page Index Changed

protected void GetSelectedRows()

{

    SessionToArrayList();

 

    foreach (GridDataItem item in RadGrid1.Items)

    {

        string CustomerID = item["CustomerID"].Text;

 

        if (item.Selected)

        {

            if (!arrayList.Contains(CustomerID))

            {

                arrayList.Add(CustomerID);

            }

        }           

        else

        {

            if (arrayList.Contains(CustomerID))

            {

                arrayList.Remove(CustomerID);

            }

        }

    }

 

    Session["selectedRows"] = arrayList;

}

 

Reselected rows when Page Index Changed

protected void ReSelectedRows()

{

    foreach (GridDataItem item in RadGrid1.MasterTableView.Items)

    {

        string CustomerID = item["CustomerID"].Text;

        if (arrayList.Contains(CustomerID))

        {

            item.Selected = true;

        }            

    }

}

 

Complete Source Code

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

 

<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

<script type="text/javascript">

 

</script>

</head>

 

<body>

    <form id="form1" runat="server">

   

    <telerik:RadGrid ID="RadGrid1" runat="server" AllowMultiRowSelection="True" 

        AllowPaging="True" DataSourceID="SqlDataSource1" GridLines="None" 

        ondatabound="RadGrid1_DataBound" onpageindexchanged="RadGrid1_PageIndexChanged" 

        Width="600px">

<MasterTableView autogeneratecolumns="False" datakeynames="CustomerID" 

            datasourceid="SqlDataSource1">

<CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>

 

<RowIndicatorColumn>

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

</RowIndicatorColumn>

 

<ExpandCollapseColumn>

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

</ExpandCollapseColumn>

    <Columns>

        <telerik:GridClientSelectColumn UniqueName="column">

        </telerik:GridClientSelectColumn>

        <telerik:GridBoundColumn DataField="CustomerID" HeaderText="CustomerID" 

            ReadOnly="True" SortExpression="CustomerID" UniqueName="CustomerID">

        </telerik:GridBoundColumn>

        <telerik:GridBoundColumn DataField="CompanyName" HeaderText="CompanyName" 

            SortExpression="CompanyName" UniqueName="CompanyName">

        </telerik:GridBoundColumn>

        <telerik:GridBoundColumn DataField="ContactName" HeaderText="ContactName" 

            SortExpression="ContactName" UniqueName="ContactName">

        </telerik:GridBoundColumn>

        <telerik:GridBoundColumn DataField="ContactTitle" HeaderText="ContactTitle" 

            SortExpression="ContactTitle" UniqueName="ContactTitle">

        </telerik:GridBoundColumn>

    </Columns>

</MasterTableView>

        <ClientSettings>

            <Selecting AllowRowSelect="True" />

        </ClientSettings>

    </telerik:RadGrid>

    <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">

    </telerik:RadScriptManager>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 

        ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 

        SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [ContactTitle] FROM [Customers]">

    </asp:SqlDataSource>

   

    </form>

    </body>

</html>

 

Default.aspx.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Collections;

using Telerik.Web.UI;

 

public partial class _Default : System.Web.UI.Page 

{

    public ArrayList arrayList = new ArrayList();

 

    protected void Page_Load(object sender, EventArgs e)

    {

        

    }

 

    protected void SessionToArrayList()

    {

        if (Session["selectedRows"] != null)

        {

            arrayList = (ArrayList)Session["selectedRows"];

        }

    }

 

    protected void GetSelectedRows()

    {

        SessionToArrayList();

 

        foreach (GridDataItem item in RadGrid1.Items)

        {

            string CustomerID = item["CustomerID"].Text;

 

            if (item.Selected)

            {

                if (!arrayList.Contains(CustomerID))

                {

                    arrayList.Add(CustomerID);

                }

            }           

            else

            {

                if (arrayList.Contains(CustomerID))

                {

                    arrayList.Remove(CustomerID);

                }

            }

        }

 

        Session["selectedRows"] = arrayList;

    }

    

    protected void ReSelectedRows()

    {

        foreach (GridDataItem item in RadGrid1.MasterTableView.Items)

        {

            string CustomerID = item["CustomerID"].Text;

            if (arrayList.Contains(CustomerID))

            {

                item.Selected = true;

            }            

        }

    }

 

    protected void RadGrid1_PageIndexChanged(object sender, GridPageChangedEventArgs e)

    {

        GetSelectedRows();

    }

    protected void RadGrid1_DataBound(object sender, EventArgs e)

    {

        ReSelectedRows();

    }

}

Add Fonts into RadComboBox (Telerik)

foreach (System.Drawing.FontFamily f in System.Drawing.FontFamily.Families)

{

    Telerik.Web.UI.RadComboBoxItem item = new Telerik.Web.UI.RadComboBoxItem();

    item.Text = f.Name;

    RadComboBox1.Items.Add(item);

}

Add Fonts into RadComboBox Telerik thumb Add Fonts into RadComboBox (Telerik)