Welcome Guest Search | Active Topics | Sign In | Register

Change style to sorted grid's column Options
Seltris
Posted: Thursday, August 7, 2008 1:00:18 AM
Rank: Member
Groups: Member

Joined: 10/4/2007
Posts: 20
Hi,

is possible to change style of sorted column??
I've try to set e.Column.CellStyle.Font.Bold = True in Grid1_ColumnSort event but nothing is happened.

you can see it in follow code:

Code: HTML/ASPX
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="Administration_Test" %>

<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>
<!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>Pagina senza titolo</title>

    <script type="text/javascript">

        refreshGrid = function () {
            function refresh() {
                var grid = eo_GetObject("Grid1");
                if (grid) grid.raiseItemCommandEvent(1, "Reload");
            };

            window.setTimeout(refresh, 1);
        };
        
    </script>

</head>
<body>
    <form id="form1" runat="server">
        <table border="0" cellpadding="0" cellspacing="5" style="width: 100%">
            <tr>
                <td>
                    <eo:Grid ID="Grid1" runat="server" AllowPaging="True" BorderColor="Gainsboro" BorderStyle="Solid"
                        BorderWidth="1px" ColumnHeaderAscImage="00050204" ColumnHeaderDescImage="00050205"
                        ColumnHeaderDividerImage="00050203" ColumnHeaderHeight="24" CssClass="EOGrid"
                        EnableKeyboardNavigation="True" Font-Bold="False" Font-Italic="False" Font-Names="Tahoma"
                        Font-Overline="False" Font-Size="8.75pt" Font-Strikeout="False" Font-Underline="False"
                        GridLineColor="240, 240, 240" GridLines="Both" ItemHeight="28" LoadingHTML="Attendere ..."
                        PagerLabelTemplate="&nbsp;" RunningMode="Callback" Width="100%">
                        <FooterStyle CssText="padding-bottom:4px;padding-left:4px;padding-right:4px;padding-top:4px;" />
                        <ItemStyles>
                            <eo:GridItemStyleSet>
                                <ItemStyle CssText="LINE-HEIGHT: 28px; BACKGROUND-COLOR: whitesmoke" />
                                <AlternatingItemStyle CssText="LINE-HEIGHT: 28px; background-color:white;" />
                                <ItemHoverStyle CssText="background-color:aliceblue;LINE-HEIGHT: 28px; " />
                                <SelectedStyle CssText="background-color:aliceblue;line-height:28px;" />
                                <FixedColumnCellStyle CssText="" />
                                <CellStyle CssText="PADDING-LEFT: 8px;vertical-align:middle" />
                            </eo:GridItemStyleSet>
                        </ItemStyles>
                        <ColumnHeaderHoverStyle CssText="background-image:url('00050202');padding-left:8px;padding-top:4px;" />
                        <Columns>
                            <eo:StaticColumn AllowSort="True" DataField="Test" HeaderText="Test" Text="">
                            </eo:StaticColumn>
                        </Columns>
                        <ColumnHeaderStyle CssText="background-image:url('00050201');padding-left:8px;padding-top:4px;" />
                    </eo:Grid>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>


Code: Visual Basic.NET
Partial Class Administration_Test
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            LoadGrid(Nothing)
        End If
    End Sub

    Private Function CreateTable() As DataTable
        Dim DT As DataTable = New DataTable
        Dim Column As DataColumn = New DataColumn("Test", GetType(String))
        DT.Columns.Add(Column)

        Return DT
    End Function

    Private Sub FillTable(ByVal DT As DataTable)
        DT.Rows.Clear()
        For Index As Integer = 1 To 10
            Dim Row As DataRow = DT.NewRow
            Row!Test = "Row " & Index
            DT.Rows.Add(Row)
        Next
    End Sub

    Private Sub LoadGrid(ByVal Column As EO.Web.GridColumn)
        Dim SortField As String = "Test"
        Dim SortDirection As String = "ASC"

        If Not Column Is Nothing AndAlso Column.DataField <> String.Empty Then
            SortField = Column.DataField
            SortDirection = IIf(Column.SortOrder = EO.Web.SortOrder.Ascending, "ASC", "DESC")
        End If

        Dim Source As DataTable = Me.CreateTable

        Me.FillTable(Source)
        Source.DefaultView.Sort = SortField & " " & SortDirection

        Me.Grid1.RecordCount = Source.Rows.Count
        Me.Grid1.DataSource = Source
        Me.Grid1.DataBind()
    End Sub

    Protected Sub Grid1_ColumnSort(ByVal sender As Object, ByVal e As EO.Web.GridColumnEventArgs) Handles Grid1.ColumnSort
        e.Column.CellStyle.Font.Bold = True
        Me.LoadGrid(e.Column)
    End Sub

End Class


Thanks
YBT Seltris
eo_support
Posted: Thursday, August 7, 2008 12:09:22 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,193
Hi,

We looked into the issue. Styles will not be updated in Callback mode. Only data are updated in Callback mode. If you wish to update style, you will want to set the Grid's running mode to "Server". You can further put the grid into a CallbackPanel or UpdatePanel to achieve similar result as in Callback mode.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.