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

Data column Type not working after upgrade

3 Answers 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David Stacey
Top achievements
Rank 1
David Stacey asked on 08 Mar 2017, 01:00 PM

We use the Telerik RadGrid in our application and load the data and columns client side.

We inherit from the Telerik grid columns

internal class xxxButtonGridBoundColumn : GridButtonColumn

internal class xxxFilterGridBoundColumn : GridBoundColumn

as part of our grid refresh we call the following JavaScript

    fixColumnType: function () {

        // force column types to be RAD types
        var TelerikGridColumns = this.get_masterTableView().get_columns();

        for (var i = 0; i < TelerikGridColumns.length; i++) {
            var column = TelerikGridColumns[i];

            switch (column._data.ColumnType) {
                case "xxxButtonGridBoundColumn":
                    column._data.ColumnType = "GridButtonColumn";
                    break;
                case "xxxFilterGridBoundColumn":
                    column._data.ColumnType = "GridBoundColumn";
                    break;

This is called before the grid.databind() method and seems to work.

The bug is that the GridButtonColumn reverts back to xxxButtonGridBoundColumn and doesn't bind to the data

(GridBoundColumn still works ok)

This was working in version 2013:3:1114:35 but broken in future versions including the most recent 2017

Any help in why this happens would be appreciated

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 10 Mar 2017, 02:57 PM
Hello David,

Please note that creating custom controls is beyond our support scope even if they are inherited directly from Telerik UI controls. Try using the default grid columns and if the issue remains, you can open a formal support thread to send us a very basic runnable version of your scenario for further investigation.

Thank you for your understanding.

Regards,
Eyup
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
David Stacey
Top achievements
Rank 1
answered on 21 Mar 2017, 10:55 AM

Hello Eyup,

I understand inherited columns are outside of your support but you do allow the use of this

http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/inheritance/inheriting-grid-columns

The code works in version 2013:3:1114:35 but does not work in the latest release. Does this not mean it's a bug as your code has changed.

I've created a very simple page that only derives from the column and nothing else. The GridButtonColumn no longer works.

Do you have any kind of work around? Changing our code to no longer use derived columns is not an option

.cs file

public partial class Default : System.Web.UI.Page
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        RadGrid1.Skin = "Metro";
        var col = new DerviedGridButtonColumn { ImageUrl = "~/placeholder.16.png", ButtonType = GridButtonColumnType.ImageButton, HeaderText = "ProductId", DataType = typeof(Int32) };
        RadGrid1.MasterTableView.Columns.Add(col);
 
        var col2 = new DerviedGridBoundColumn { HeaderText = "ProductName", DataType = typeof(String), DataField = "ProductName" };
        RadGrid1.MasterTableView.Columns.Add(col2);
    }
}
 
public class DerviedGridButtonColumn : GridButtonColumn
{
}
 
public class DerviedGridBoundColumn : GridBoundColumn
{
}

 

.aspx file

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <script type="text/javascript">
        function pageLoad() {
 
            // force column types to be RAD types
            var TelerikGridColumns = $find('<%=RadGrid1.ClientID %>').get_masterTableView().get_columns();
 
            for (var i = 0; i < TelerikGridColumns.length; i++) {
                var column = TelerikGridColumns[i];
 
                switch (column._data.ColumnType) {
                    case "DerivedGridButtonColumn":
                        column._data.ColumnType = "GridButtonColumn";
                        break;
                    case "DerivedGridBoundColumn":
                        column._data.ColumnType = "GridBoundColumn";
                        break;
                }
            }
        }
    </script>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
    <div>
        <telerik:RadGrid  runat="server" ID="RadGrid1" AllowPaging="false" AllowSorting="false" EnableLinqExpressions ="false" AllowFilteringByColumn="false">
            <MasterTableView DataKeyNames="ProductID" ClientDataKeyNames="ProductID">
                <PagerStyle Mode="NumericPages" />
            </MasterTableView>
           <ClientSettings>
                <DataBinding SelectMethod="GetDataAndCount" Location="~/WebService.asmx" >
                </DataBinding>
            </ClientSettings>
        </telerik:RadGrid>  
    </div>
    </form>
</body>
</html>
0
Eyup
Telerik team
answered on 24 Mar 2017, 09:38 AM
Hello David,

I've already replied to this query in ticket with ID: 1099533. I suggest that we continue our conversation on the mentioned thread.

Regards,
Eyup
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
David Stacey
Top achievements
Rank 1
Answers by
Eyup
Telerik team
David Stacey
Top achievements
Rank 1
Share this question
or