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

GridImageColumn not Sortable

6 Answers 147 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fred Wesson
Top achievements
Rank 1
Fred Wesson asked on 11 Aug 2011, 10:17 PM
I have a RadGrid with a GridImageColumn in it.  I have enabled sorting and am able to sort all columns except the GridImageColumn.  When I move the mouse over the GridImageColumn header, I do not have the option to click on it.  I have gone through the example and can't see what I'm missing.  I am assigning the image using the ItemDataBound event (see below).  Seems like it must be something simple...

Here is the RadGrid definition:
    <telerik:RadGrid ID="grdMain" runat="server" Width="100%" AutoGenerateColumns="False" ShowFooter="false" 
                                        GridLines="None" AllowMultiRowSelection="True" 
                                        BorderStyle="None" GroupingEnabled="False" 
        Skin="Windows7" onitemcommand="grdMain_ItemCommand" 
        onitemdatabound="grdMain_ItemDataBound" 
        onsortcommand="grdMain_SortCommand" AllowSorting="True">
    <ItemStyle Wrap="False" />
    <MasterTableView TableLayout="Fixed" Width="100%" >
    <RowIndicatorColumn>
    <HeaderStyle></HeaderStyle>
    </RowIndicatorColumn>
    <ExpandCollapseColumn>
    <HeaderStyle></HeaderStyle>
    </ExpandCollapseColumn>
        <Columns>
            <telerik:GridClientSelectColumn Resizable="false" Visible="true">
                <HeaderStyle Width="30px" />
            </telerik:GridClientSelectColumn>
            <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="cmdView" ImageUrl="~/images/properties.png" UniqueName="View">
                <HeaderStyle Width="25px" />
            </telerik:GridButtonColumn>
            <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="cmdUpdate" ImageUrl="~/images/edit.png" UniqueName="Update">
                <HeaderStyle Width="25px" />
            </telerik:GridButtonColumn>
            <telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name" 
                UniqueName="FirstName" DataFormatString="<nobr>{0}</nobr>">
                <HeaderStyle Width="100px" />
                <FooterStyle />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="LastName" HeaderText="Last Name" 
                UniqueName="LastName">
                <HeaderStyle />
                <ItemStyle />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="CardCode" HeaderText="Prox Card Code" 
                UniqueName="CardCode">
                <HeaderStyle Width="100px" />
                <ItemStyle />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="DoorCode" HeaderText="Door Code"
                UniqueName="DoorCode" DataFormatString="<nobr>{0}</nobr>">
                <HeaderStyle Width="100px" />
                <FooterStyle />
            </telerik:GridBoundColumn>
            <telerik:GridImageColumn DataType="System.Int32" HeaderText="Enabled" DataImageUrlFields="Enabled" ImageAlign="Middle" AllowSorting="true"
                UniqueName="Enabled">
                <HeaderStyle Width="100px" HorizontalAlign="Center" />
                <ItemStyle HorizontalAlign="Center" />
            </telerik:GridImageColumn>
        </Columns>
    </MasterTableView>
                    <HeaderStyle BorderStyle="Solid" BorderWidth="1px" Wrap="true" />
                    <ClientSettings AllowKeyboardNavigation="True" AllowRowsDragDrop="False">
                        <Selecting AllowRowSelect="True" />
                        <Scrolling AllowScroll="false" UseStaticHeaders="True" />
                        <Resizing AllowColumnResize="true" ClipCellContentOnResize="true" ResizeGridOnColumnResize="true" />
                    </ClientSettings>
                    <FooterStyle Wrap="false" />
</telerik:RadGrid

ItemDataBound Event:
if (e.Item is GridDataItem)
 {
       e.Item.Cells[grdMain.Columns.FindByUniqueName("Update").OrderIndex].ToolTip = "Update";
       e.Item.Cells[grdMain.Columns.FindByUniqueName("View").OrderIndex].ToolTip = "View";
                  
       bool _SystemAdmin = Convert.ToBoolean(DataBinder.Eval(e.Item.DataItem, "Enabled"));
       ((Image)(((GridDataItem)e.Item)["Enabled"].Controls[0])).ImageUrl = "~/images/check_mark_checked.png";
       if (!_SystemAdmin)
       {
           ((Image)(((GridDataItem)e.Item)["Enabled"].Controls[0])).ImageUrl = "~/images/check_mark_unchecked.png";
       }
   }

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Aug 2011, 04:36 AM
Hello Fred,

Please check out the following forum, I hope it will help you to achieve the requirement.
 RadGrid image column not updating when sorting

Thanks,
Princy.

0
Fred Wesson
Top achievements
Rank 1
answered on 12 Aug 2011, 06:33 PM
I have read the thread on the image column not updating.  I'm having a different problem.  The GridImageColumn in my grid is not sortable (you cannot click on the header text to sort it).  It's as if AllowSorting is set to False, even though it is not.
0
Radoslav
Telerik team
answered on 16 Aug 2011, 11:55 AM
Hi Fred,

Please check out the following online example which contains the RadGrid with sortable GridImageColumn and let me know what differs in your case.
Looking forward for your reply.

Best wishes,
Radoslav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Fred Wesson
Top achievements
Rank 1
answered on 16 Aug 2011, 02:23 PM
I've looked at online example several times and I don't see any differences.
0
Radoslav
Telerik team
answered on 19 Aug 2011, 11:51 AM
Hello Fred,

Based on the provided information is hard to say what is caused the described issue. Could you please send us a sample where we could replicate the issue. We will debug it locally and get to the source of the problem. You could open a formal support ticket from your Telerik account and attach a ZIP file there. Thus we will be able to gather more details about your scenario and to provide you a solution.

All the best,
Radoslav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Accepted
Eric
Top achievements
Rank 1
answered on 16 Apr 2012, 01:43 PM
Hello,
Depending on the version of Telerik components you are using, the sort expression is not automatically inferred by the DataImageUrlFields key.
.
If you explicitely add a SortExpression value to the GridImageColumn, sorting should work properly

In your example, it should be :
<telerik:GridImageColumn DataType="System.Int32" HeaderText="Enabled"
      DataImageUrlFields="Enabled" ImageAlign="Middle"
      AllowSorting="true" SortExpression="Enabled"
      UniqueName="Enabled">
             <HeaderStyle Width="100px" HorizontalAlign="Center" />
             <ItemStyle HorizontalAlign="Center" />
</telerik:GridImageColumn>

Hope it helps,
Tags
Grid
Asked by
Fred Wesson
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Fred Wesson
Top achievements
Rank 1
Radoslav
Telerik team
Eric
Top achievements
Rank 1
Share this question
or