Problem with RadGrid

1 posts, 0 answers
  1. Sasha
    Sasha avatar
    4 posts
    Member since:
    Apr 2014

    Posted 18 Apr Link to this post

    Hello!
    I have a grid with frozen columns and grouping. When the grid loads without horizontal scrolling and has hidden columns, I discovered two problems:
    1) after displaying hidden columns manually and when horizontal scrolling becomes available - we can scroll the grid data, but the grid headers do not scroll
    2) the “colspan” parameter is incorrectly calculated if some columns were hidden when the page was loaded.

    it is my .aspx code:

    01.<%@ Page Language="VB" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="TelerikWebApp1._Default" %>
    02. 
    03.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    04. 
    06.<head runat="server">
    07.    <title></title>
    08.    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
    09.</head>
    10.<body>
    11.    <form id="form1" runat="server">
    12.    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    13.        <Scripts>
    14.            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
    15.            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
    16.            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
    17.        </Scripts>
    18.    </telerik:RadScriptManager>
    19.    <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server" EnableHeaderContextMenu="true"
    20.        ClientSettings-ClientEvents-OnColumnShown="ColumnShown" ClientSettings-ClientEvents-OnColumnHidden="ColumnHidden">
    21.        <ClientSettings>
    22.            <Scrolling AllowScroll="True" UseStaticHeaders="True" FrozenColumnsCount="4"></Scrolling>
    23.        </ClientSettings>
    24.        <MasterTableView ></MasterTableView>
    25.        <HeaderStyle Width="200px" />
    26.    </telerik:RadGrid>
    27.    <script type="text/javascript">
    28.        //Put your JavaScript code here.
    29.        function ColumnHidden(sender, eventArgs) {}
    30.        function ColumnShown(sender, eventArgs) {}
    31.    </script>
    32.    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    33.    </telerik:RadAjaxManager>
    34.    <div>
    35. 
    36.    </div>
    37.    </form>
    38.</body>
    39.</html>

    and it is my .vb code

    001.Imports Telerik.Web.Data
    002.Imports Telerik.Web.UI
    003. 
    004.Partial Class _Default
    005.    Inherits System.Web.UI.Page
    006. 
    007.    Private Sub _Default_LoadComplete(sender As Object, e As EventArgs) Handles Me.LoadComplete
    008.        RadGrid1.MasterTableView.GetColumnSafe("Custom1").Display = False
    009.        RadGrid1.MasterTableView.GetColumnSafe("Custom2").Display = False
    010.        RadGrid1.MasterTableView.GetColumnSafe("Custom3").Display = False
    011.        RadGrid1.MasterTableView.GetColumnSafe("Custom4").Display = False
    012.        RadGrid1.MasterTableView.GetColumnSafe("Custom5").Display = False
    013.        RadGrid1.MasterTableView.GetColumnSafe("Custom6").Display = False
    014.        RadGrid1.MasterTableView.GetColumnSafe("Custom7").Display = False
    015.        RadGrid1.MasterTableView.GetColumnSafe("Custom8").Display = False
    016.        RadGrid1.MasterTableView.GetColumnSafe("Custom9").Display = False
    017.        'RadGrid1.MasterTableView.GetColumnSafe("MainMaterial").Display = False
    018.        RadGrid1.MasterTableView.GetColumnSafe("ComponentOrder").Display = False
    019.    End Sub
    020. 
    021.    Private Sub _Default_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender
    022. 
    023.    End Sub
    024. 
    025.    Private Sub RadGrid1_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
    026.        Dim list As List(Of PersonData) = New List(Of PersonData)
    027.        list.Add(New PersonData(1, "Name1", 11, "", "", "", "", "", "", "", "", "", "1", "Test", 1))
    028.        list.Add(New PersonData(2, "Name2", 12, "", "", "", "", "", "", "", "", "", "1", "Test", 1))
    029.        list.Add(New PersonData(3, "Name3", 13, "", "", "", "", "", "", "", "", "", "1", "Test", 0))
    030.        list.Add(New PersonData(4, "Name4", 14, "", "", "", "", "", "", "", "", "", "1", "Test", 0))
    031.        RadGrid1.DataSource = list
    032. 
    033.        RadGrid1.GroupingEnabled = True
    034.        RadGrid1.GroupingSettings.ShowUnGroupButton = False
    035.        RadGrid1.ShowGroupPanel = False
    036.        RadGrid1.GroupingSettings.GroupContinuesFormatString = ""
    037. 
    038.        RadGrid1.MasterTableView.GroupByExpressions.Clear()
    039.        Dim selfield As GridGroupByField = New GridGroupByField()
    040.        selfield.FieldName = "MainMaterial"
    041.        'Do not use GetsystemText here its defined in Itemdatabound.
    042.        selfield.HeaderText = "Main Material"
    043.        Dim grpfield As GridGroupByField = New GridGroupByField()
    044.        grpfield.FieldName = "MainMaterial"
    045.        grpfield.SortOrder = GridSortOrder.Descending
    046.        Dim expression3 As GridGroupByExpression = New GridGroupByExpression()
    047.        expression3.GroupByFields.Add(grpfield)
    048.        expression3.SelectFields.Add(selfield)
    049.        RadGrid1.MasterTableView.GroupByExpressions.Add(expression3)
    050.        Dim selfield2 As GridGroupByField = New GridGroupByField()
    051.        selfield2.FieldName = "ComponentDescription"
    052.        selfield2.HeaderText = "Material Type"
    053.        Dim grpfield2 As GridGroupByField = New GridGroupByField() With {.FieldName = "ComponentOrder"}
    054.        Dim grpfield3 As GridGroupByField = New GridGroupByField() With {.FieldName = "ComponentDescription"}
    055.        Dim expression4 As GridGroupByExpression = New GridGroupByExpression()
    056.        expression4.GroupByFields.Add(grpfield2)
    057.        expression4.GroupByFields.Add(grpfield3)
    058.        expression4.SelectFields.Add(selfield2)
    059.        RadGrid1.MasterTableView.GroupByExpressions.Add(expression4)
    060. 
    061.    End Sub
    062. 
    063.    Public Class PersonData
    064.        Private _ID As Int16
    065.        Private _Name As String
    066.        Private _Age As Int16
    067.        Private _Custom1 As String
    068.        Private _Custom2 As String
    069.        Private _Custom3 As String
    070.        Private _Custom4 As String
    071.        Private _Custom5 As String
    072.        Private _Custom6 As String
    073.        Private _Custom7 As String
    074.        Private _Custom8 As String
    075.        Private _Custom9 As String
    076. 
    077.        Private _MainMaterial As Int16
    078.        Private _ComponentOrder As String
    079.        Private _ComponentDescription As String
    080. 
    081.        Public Sub New(ByVal id As Int16, ByVal name As String, ByVal age As Int16,
    082.                       ByVal custom1 As String,
    083.                       ByVal custom2 As String,
    084.                       ByVal custom3 As String,
    085.                       ByVal custom4 As String,
    086.                       ByVal custom5 As String,
    087.                       ByVal custom6 As String,
    088.                       ByVal custom7 As String,
    089.                       ByVal custom8 As String,
    090.                       ByVal custom9 As String,
    091.                       ByVal componentOrder As String,
    092.                       ByVal componentDescription As String,
    093.                       ByVal mainMaterial As Int16)
    094. 
    095.            _ID = id
    096.            _Name = name
    097.            _Age = age
    098. 
    099.            _ComponentOrder = componentOrder
    100.            _ComponentDescription = componentDescription
    101.            _MainMaterial = mainMaterial
    102. 
    103.        End Sub
    104. 
    105.        Public Property ID() As Int16
    106.            Get
    107.                Return _ID
    108.            End Get
    109.            Set(ByVal Value As Int16)
    110.                _ID = Value
    111.            End Set
    112.        End Property
    113. 
    114.        Public Property MainMaterial() As Int16
    115.            Get
    116.                Return _MainMaterial
    117.            End Get
    118.            Set(ByVal Value As Int16)
    119.                _MainMaterial = Value
    120.            End Set
    121.        End Property
    122. 
    123.        Public Property ComponentOrder() As String
    124.            Get
    125.                Return _ComponentOrder
    126.            End Get
    127.            Set(ByVal Value As String)
    128.                _ComponentOrder = Value
    129.            End Set
    130.        End Property
    131. 
    132.        Public Property ComponentDescription() As String
    133.            Get
    134.                Return _ComponentDescription
    135.            End Get
    136.            Set(ByVal Value As String)
    137.                _ComponentDescription = Value
    138.            End Set
    139.        End Property
    140. 
    141.        Public Property Name() As String
    142.            Get
    143.                Return _Name
    144.            End Get
    145.            Set(ByVal Value As String)
    146.                _Name = Value
    147.            End Set
    148.        End Property
    149. 
    150.        Public Property Custom1() As String
    151.            Get
    152.                Return _Custom1
    153.            End Get
    154.            Set(ByVal Value As String)
    155.                _Custom1 = Value
    156.            End Set
    157.        End Property
    158. 
    159.        Public Property Custom2() As String
    160.            Get
    161.                Return _Custom2
    162.            End Get
    163.            Set(ByVal Value As String)
    164.                _Custom2 = Value
    165.            End Set
    166.        End Property
    167. 
    168.        Public Property Custom3() As String
    169.            Get
    170.                Return _Custom3
    171.            End Get
    172.            Set(ByVal Value As String)
    173.                _Custom3 = Value
    174.            End Set
    175.        End Property
    176. 
    177.        Public Property Custom4() As String
    178.            Get
    179.                Return _Custom4
    180.            End Get
    181.            Set(ByVal Value As String)
    182.                _Custom4 = Value
    183.            End Set
    184.        End Property
    185. 
    186.        Public Property Custom5() As String
    187.            Get
    188.                Return _Custom5
    189.            End Get
    190.            Set(ByVal Value As String)
    191.                _Custom5 = Value
    192.            End Set
    193.        End Property
    194. 
    195.        Public Property Custom6() As String
    196.            Get
    197.                Return _Custom6
    198.            End Get
    199.            Set(ByVal Value As String)
    200.                _Custom6 = Value
    201.            End Set
    202.        End Property
    203. 
    204.        Public Property Custom7() As String
    205.            Get
    206.                Return _Custom7
    207.            End Get
    208.            Set(ByVal Value As String)
    209.                _Custom7 = Value
    210.            End Set
    211.        End Property
    212. 
    213.        Public Property Custom8() As String
    214.            Get
    215.                Return _Custom8
    216.            End Get
    217.            Set(ByVal Value As String)
    218.                _Custom8 = Value
    219.            End Set
    220.        End Property
    221. 
    222.        Public Property Custom9() As String
    223.            Get
    224.                Return _Custom9
    225.            End Get
    226.            Set(ByVal Value As String)
    227.                _Custom9 = Value
    228.            End Set
    229.        End Property
    230. 
    231.        Public Property Age() As Int16
    232.            Get
    233.                Return _Age
    234.            End Get
    235.            Set(ByVal Value As Int16)
    236.                _Age = Value
    237.            End Set
    238.        End Property
    239. 
    240.    End Class
    241. 
    242.End Class



    And also I have a question about the work of the grouping. In our project we have a lot of grids, and all of them have the same markup(it is example https://prnt.sc/ndptj5), but the two grids have a different markup to grouping the rows(it is different example https://prnt.sc/ndpw3r). I do not know which parameter makes these changes, can you help me?

    I am using the latest version of Telerik - 2019.1.215.45

Back to Top