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

Sorting on GridImageColumn

3 Answers 212 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike Kacos
Top achievements
Rank 1
Mike Kacos asked on 06 May 2010, 03:58 PM
Hi,
    I have a grid, that has a GridImageColumn.  The imageUrl is working correctly, and on ItemDataBound I Clear the image out from some rows, so I am left with a grid that has some rows with an image and some without in the same column.  My question is simply, is there a way to sort on that column??  I tried adding an invisible GridBoundColumn which I would populate with either a "1" or a "0" and set my sort expression to that column and set AllowSorting to true, but when I click on the column header I receive an error that says Cannot find column, so I think that's the wrong approach.  See code below.

Any help will be greatly appreciated.

Thanks,

-Mike

 <ngc:NGCGrid ID="grdItems" runat="server" AllowPaging="True" AllowSorting="True" 
        AllowMultiRowSelection="True" GridLines="None" AutoGenerateColumns="False" PageSize="500" 
        OnNeedDataSource="grdItems_NeedSource" EnableViewState="true" AllowAutomaticDeletes="true" 
        OnItemCommand="grdItems_ItemCommand" OnItemDataBound="grdItems_ItemDataBound" 
        OnItemCreated="grdItems_ItemCreated" OnItemUpdated="grdItems_ItemUpdated" OnItemInserted="grdItems_ItemInserted" 
        OnItemDeleted="grdItems_ItemDeleted">  
        <ClientSettings AllowKeyboardNavigation="True" > 
            <Scrolling AllowScroll="true" ScrollHeight="440px" UseStaticHeaders="true" /> 
            <Selecting AllowRowSelect="true" /> 
        </ClientSettings> 
        <MasterTableView CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add Item" 
            EditMode="InPlace" DataKeyNames="ITEM_ID">  
            <CommandItemTemplate > 
                <div style="padding: 5px 5px;">  
 
                 <asp:LinkButton ID="LinkButton2" runat="server" CommandName="InitInsert" > 
                 <img style="border:0px;vertical-align:middle;" alt="" src="../../App_Themes/SpidersTheme/Grid/AddRecord.gif" />Add new Item  
                 </asp:LinkButton>&nbsp;&nbsp;  
 
                <asp:LinkButton ID="LinkButton1" OnClientClick="javascript:return confirm('Are you sure you want to delete all selected Items?')" 
                    runat="server" CommandName="DeleteSelected">  
                    <img style="border:0px;vertical-align:middle;" alt="" src="../../App_Themes/SpidersTheme/Grid/Delete.gif" />Delete selected Items</asp:LinkButton>&nbsp;&nbsp;  
                </div> 
            </CommandItemTemplate> 
            <Columns> 
                <telerik:GridClientSelectColumn> 
                    <HeaderStyle Width="10px" /> 
                    <ItemStyle Width="10px" /> 
                </telerik:GridClientSelectColumn> 
                <telerik:GridEditCommandColumn ButtonType="ImageButton">  
                    <HeaderStyle Width="35px" /> 
                    <ItemStyle Width="35px" /> 
                </telerik:GridEditCommandColumn> 
                <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="ImageButton" 
                    ConfirmText="Are you sure you want to delete this item?">  
                    <HeaderStyle Width="10px" /> 
                    <ItemStyle Width="10px" /> 
                </telerik:GridButtonColumn> 
                <telerik:GridImageColumn UniqueName="FilteredFlag" ImageUrl="../../Common/Images/green_flag_16x16.png" AllowSorting="true"   
                HeaderImageUrl="../../Common/Images/green_flag_16x16.png" SortExpression="FilterFlagOrder"  > 
                <HeaderStyle Width="10px" /> 
                    <ItemStyle Width="10px" /> 
                      
                </telerik:GridImageColumn> 
                <telerik:GridBoundColumn UniqueName="FilterFlagOrder" Visible="true">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="NSN" HeaderText="NSN" UniqueName="NSN" ColumnEditorID="GridTextBoxColumnEditor1" > 
                    <HeaderStyle Width="120px" /> 
                    <ItemStyle Width="120px" /> 
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="ITEM_DESCRIPTION" HeaderText="Description" UniqueName="ITEM_DESCRIPTION" 
                    ColumnEditorID="GridTextBoxColumnEditor2">  
                    <HeaderStyle Width="300px" /> 
                    <ItemStyle Width="300px" /> 
                </telerik:GridBoundColumn> 
                <telerik:GridNumericColumn DataField="USAGE_FACTOR" HeaderText="Factor" UniqueName="USAGE_FACTOR" 
                    ColumnEditorID="GridNumericColumnEditor1">  
                    <HeaderStyle Width="40px" /> 
                    <ItemStyle Width="40px" /> 
                </telerik:GridNumericColumn> 
                <telerik:GridHyperLinkColumn Text="Search">  
                      
                </telerik:GridHyperLinkColumn> 
                  
            </Columns> 
        </MasterTableView> 
    </ngc:NGCGrid> 
    <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor1" runat="server" TextBoxStyle-Width="120px" /> 
    <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor2" runat="server" TextBoxStyle-Width="300px" /> 
    <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server" NumericTextBox-Width="40px" /> 

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 06 May 2010, 04:05 PM
Hello Mike,

Please refer to the forum thread below which elaborates on this matter, for more information about how to achieve the desired functionality.
http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-image-column-not-updating-when-sorting.aspx

I hope this helps.

Kind regards,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mike Kacos
Top achievements
Rank 1
answered on 06 May 2010, 04:15 PM
Hi, thanks, but I already went through that thread.  Maybe I'm missing something, but it sounds like that users's issue was updating images on sorting.  I'm just trying to get the sort to happen.  I don't need to update the images, just simply sort on the Image Column.
0
Pavlina
Telerik team
answered on 07 May 2010, 09:27 AM
Hi Mike,

Please examine the online example below where the GridImageColumn is sorted as expected and see if it helps to resolve the issue you are facing:
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/columntypes/defaultcs.aspx

If the problem persists at your end, you can open a formal support ticket and send me a small working project, demonstrating your setup, and showing the issue. I will review it locally, and get back to you with more information on the matter.

Regards,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Mike Kacos
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Mike Kacos
Top achievements
Rank 1
Share this question
or