This is a migrated thread and some comments may be shown as answers.

How to detect if a column was dragged *off* a RadGrid?

1 Answer 21 Views
This is a migrated thread and some comments may be shown as answers.
Missing User
Missing User asked on 19 Jun 2012, 05:12 PM

I have a RadGrid on my page, and have the ReorderColumnsOnClient property set to true. This all works fine.

However, I also have a requirement to hide columns which are dragged *off* the grid.

Anybody have any ideas on how I might do this?

PS - I'd prefer to do this with the the regular Telerik events, as opposed to using undocumented functionality which might break on the next version.

Here's the prototype aspx I created.

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
        How do I detect a column has been dragged off the grid?
    <asp:ScriptManager runat="server" />
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
        <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">
        <MasterTableView DataKeyNames="ProductID" DataSourceID="SqlDataSource1">
            <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
                <HeaderStyle Width="20px"></HeaderStyle>
                <HeaderStyle Width="20px"></HeaderStyle>
                <telerik:GridBoundColumn DataField="ProductID" DataType="System.Int32" HeaderText="ProductID"
                    ReadOnly="True" SortExpression="ProductID" UniqueName="ProductID">
                <telerik:GridBoundColumn DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName"
                <telerik:GridBoundColumn DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName"
                <telerik:GridBoundColumn DataField="UnitPrice" DataType="System.Decimal" HeaderText="UnitPrice"
                    SortExpression="UnitPrice" UniqueName="UnitPrice">
                <telerik:GridBoundColumn DataField="UnitsInStock" DataType="System.Int16" HeaderText="UnitsInStock"
                    SortExpression="UnitsInStock" UniqueName="UnitsInStock">
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT [ProductID], [ProductName], [CategoryName], [UnitPrice], [UnitsInStock] FROM [Alphabetical list of products]">

And the web.config's 
<add name="NorthwindConnectionString" connectionString="Data Source=.;Initial Catalog=Northwind;Integrated Security=True" providerName="System.Data.SqlClient" />

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 20 Jun 2012, 03:12 PM
Hello John,

I am afraid the described behaviour is not supported since no event to handle the column drop is exposed. I know it is not the same thing,however, as an alternative to this feature I could suggest you the HeaderContextMenu:
Grid / Header Context Menu

the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Asked by
Missing User
Answers by
Telerik team
Share this question