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

The grid sorts on pressing enter key while grouped.

7 Answers 125 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Das
Top achievements
Rank 1
Das asked on 04 Feb 2009, 12:33 PM
Hi,

I have a grid with grouping enabled. I am using RADAjaxManager to enable Ajax in the page. I grouped the resultset with one column. When I press enter with the focus in any one of the filter textboxes the grid sorts based on the grouped column. This happens only for the first time. What is the issue here? How do I access the image button with column name on the top to suppress it? Is there any workaround I can get? Thanks in advance. Any help would be highly appreciated. This is happening in all the grids I have. I have added the grid code.

<

rad:RadGrid ID="rgVessel" CssClass="ms-WPTitle" AutoGenerateColumns="False"

 

 

PageSize="10" AllowPaging="True" AllowSorting="True" runat="server" Width="100%"

 

 

AllowFilteringByColumn="True" OnItemDataBound="rgVessel_OnItemDataBound" HorizontalAlign="NotSet"

 

 

FilterMenu-CssClass="FilterMenuClass1" ShowGroupPanel="True" Skin="Default" OnNeedDataSource="rgVessel_OnNeedDataSource"

 

 

OnDataBound="rgVessels_DataBound" OnItemCreated="rgVessel_OnItemCreated" OnPreRender = "rgVessel_PreRender">

 

 

<SelectedItemStyle Font-Bold="true" />

 

 

<ClientSettings AllowColumnsReorder="True" AllowDragToGroup="True">

 

 

<Scrolling UseStaticHeaders="True" ScrollHeight="350px" AllowScroll="True" />

 

 

<Resizing AllowColumnResize="True" AllowRowResize="True" />

 

 

</ClientSettings>

 

 

<MasterTableView GridLines="None" CommandItemDisplay="Top">

 

 

<CommandItemStyle HorizontalAlign="right" />

 

 

<CommandItemTemplate>

 

 

<asp:LinkButton ID="lnkRefresh" runat="server" CommandName="RebindGrid"><img style="border:0px" alt="" src="/wpresources/VesselAssurance/Images/Refresh.gif" /> Refresh</asp:LinkButton>

 

 

</CommandItemTemplate>

 

 

<Columns>

 

 

<rad:GridTemplateColumn UniqueName="TemplateColumn1" DataField="VesselID" DataType="System.Int32"

 

 

HeaderText="Serial Number" SortExpression="VesselID" Groupable="false" HeaderStyle-Width="120px" ItemStyle-Width="70px">

 

 

<ItemStyle HorizontalAlign="Center" />

 

 

<ItemTemplate>

 

 

<asp:LinkButton Text='<%#DataBinder.Eval(Container.DataItem,"VesselID")%>' style="cursor:pointer;" runat=server ID="lnkVesselDetails" OnClick="lnkVesselDetails_Click"></asp:LinkButton>

 

 

</ItemTemplate>

 

 

<HeaderTemplate>

 

S.No

 

</HeaderTemplate>

 

 

</rad:GridTemplateColumn>

 

<%

------------------------------------------------------- --%>

 

 

<rad:GridTemplateColumn Visible="True" UniqueName="VesselsReport" HeaderText="Report"

 

 

AllowFiltering="false" Groupable="false" HeaderStyle-Width="90px" ItemStyle-Width="70px" ItemStyle-HorizontalAlign="Center">

 

 

<ItemTemplate>

 

 

<img style="cursor: pointer;" src="/RadControls/Grid/Skins/Default/notes.gif" alt="Report"

 

 

onclick="javascript:OpenReportWindow('<%#DataBinder.Eval(Container.DataItem,"VesselID")%>')" />

 

 

</ItemTemplate>

 

 

</rad:GridTemplateColumn>

 

<%

---------------------------------------------------------%>

 

 

<rad:GridTemplateColumn UniqueName="TemplateColumn3" DataField="VesselShortdesc" HeaderStyle-Width="90px" ItemStyle-Width="50px"

 

 

AllowFiltering="false" Groupable="false" SortExpression="VesselShortdesc" HeaderText="Vessel Status Indicator">

 

 

<ItemStyle HorizontalAlign="Center" />

 

 

<ItemTemplate>

 

<%

-- <img src='/wpresources/vesselassurance/images/<%#DataBinder.Eval(Container.DataItem,"ColorCode")%>' alt="" />--%>

 

<%

#GetColorCodePath(DataBinder.Eval(Container.DataItem,"ColorCode"))%>

 

 

</ItemTemplate>

 

 

<HeaderTemplate>

 

Vessel Status Indicator

 

</HeaderTemplate>

 

 

</rad:GridTemplateColumn>

 

 

<rad:GridTemplateColumn UniqueName="TemplateColumn2" DataField="VesselName" FilterListOptions="AllowAllFilters"

 

 

HeaderText="Vessel Name" SortExpression="VesselName" Groupable="false" HeaderStyle-Width="126px" ItemStyle-Width="126px">

 

 

<ItemStyle HorizontalAlign="Left" />

 

 

<ItemTemplate>

 

 

<div style="cursor: pointer;" onclick="javascript:OpenWindow('<%#DataBinder.Eval(Container.DataItem,"VesselID")%>','Vessels')">

 

 

<span><u>

 

<%

#DataBinder.Eval(Container.DataItem, "VesselName")%>

 

 

</u></span>

 

 

</div>

 

 

</ItemTemplate>

 

 

<HeaderTemplate>

 

Vessel Name

 

</HeaderTemplate>

 

 

</rad:GridTemplateColumn>

 

 

<rad:GridBoundColumn DataField="VesselID" UniqueName="VesselID" Visible="False" HeaderText="S.No">

 

 

</rad:GridBoundColumn>

 

 

<rad:GridBoundColumn DataField="VesselName" UniqueName="VesselName" Visible="False"

 

 

HeaderText="Vessel Name">

 

 

</rad:GridBoundColumn>

 

 

<rad:GridBoundColumn DataField="SPUName" UniqueName="SPUName" HeaderText="SPU Name" HeaderStyle-Width="110px" ItemStyle-Width="120px">

 

 

</rad:GridBoundColumn>

 

 

<rad:GridBoundColumn DataField="IMONum" UniqueName="IMONum" HeaderText="IMO Number" HeaderStyle-Width="110px" ItemStyle-Width="120px">

 

 

</rad:GridBoundColumn>

 

 

<rad:GridBoundColumn DataField="CMID_Dt" DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy }"

 

 

UniqueName="CMID_Dt" HeaderText="CMID" HeaderStyle-Width="110px" ItemStyle-Width="120px">

 

 

</rad:GridBoundColumn>

 

 

<rad:GridBoundColumn DataField="CMIDReview_Dt" DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy }"

 

 

UniqueName="CMIDReview_Dt" HeaderText="CMID Review" HeaderStyle-Width="110px" ItemStyle-Width="120px">

 

 

</rad:GridBoundColumn>

 

 

<rad:GridBoundColumn DataField="DPTrial_Dt" DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy }"

 

 

UniqueName="DPTrial_Dt" HeaderText="DP Trial" HeaderStyle-Width="110px" ItemStyle-Width="120px">

 

 

</rad:GridBoundColumn>

 

 

<rad:GridBoundColumn DataField="FMEA_Dt" DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy }"

 

 

UniqueName="FMEA_Dt" HeaderText="FMEA" HeaderStyle-Width="110px" ItemStyle-Width="120px">

 

 

</rad:GridBoundColumn>

 

 

<rad:GridBoundColumn DataField="Struct_Dt" DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy }"

 

 

UniqueName="Struct_Dt" HeaderText="Structural Audit" HeaderStyle-Width="110px" ItemStyle-Width="120px">

 

 

</rad:GridBoundColumn>

 

 

<rad:GridBoundColumn ItemStyle-HorizontalAlign="center" DataField="Drydock" DataType="System.DateTime"

 

 

DataFormatString="{0:MM/dd/yyyy }" UniqueName="Drydock" HeaderText="Dry Dock" HeaderStyle-Width="110px" ItemStyle-Width="120px">

 

 

</rad:GridBoundColumn>

 

 

<rad:GridBoundColumn DataField="RetiredDt" DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy }"

 

 

UniqueName="RetiredDt" HeaderText="Expiry Date" HeaderStyle-Width="110px" ItemStyle-Width="120px">

 

 

</rad:GridBoundColumn>

 

 

<rad:GridBoundColumn DataField="VesselShortdesc" SortExpression="VesselShortdesc"

 

 

UniqueName="VesselShortdesc" Visible="True" HeaderText="Vessel Status" HeaderStyle-Width="126px" ItemStyle-Width="126px">

 

 

</rad:GridBoundColumn>

 

 

<rad:GridBoundColumn DataField="VesselTypeCode" UniqueName="VesselTypeCode" HeaderText="Vessel Type" HeaderStyle-Width="126px" ItemStyle-Width="126px">

 

 

</rad:GridBoundColumn>

 

<%

------------------------------------------------------- --%>

 

 

<rad:GridTemplateColumn Visible="True" UniqueName="VesselsHistory" AllowFiltering="false"

 

 

Groupable="false" HeaderStyle-Width="20px" ItemStyle-Width="20px">

 

 

<ItemTemplate>

 

 

<img style="cursor: pointer;" src="/RadControls/Grid/Skins/Default/history.gif" alt="Audit"

 

 

onclick="javascript:OpenHistoryWindow('<%#DataBinder.Eval(Container.DataItem,"VesselID")%>')" />

 

 

</ItemTemplate>

 

 

</rad:GridTemplateColumn>

 

<%

---------------------------------------------------------%>

 

 

<rad:GridTemplateColumn HeaderText=" " UniqueName="TemplateColumn2" AllowFiltering="false"

 

 

Groupable="false" HeaderStyle-Width="20px" ItemStyle-Width="20px">

 

 

<ItemTemplate>

 

 

<!--<img style="cursor: pointer;" src="/RadControls/Grid/Skins/Default/Delete.gif" alt="Del"

 

onclick="javascript:postBack_Delete('<%#DataBinder.Eval(Container.DataItem,"VesselID")%>')" />-->

 

<asp:Button UseSubmitBehavior="false" ID="imgDelete" runat="server" style="cursor: pointer;" ImageUrl="/RadControls/Grid/Skins/Default/Delete.gif" AlternateText="Del"

 

 

OnClick="imgDelete_Click" />

 

 

</ItemTemplate>

 

 

</rad:GridTemplateColumn>

 

 

</Columns>

 

 

<ExpandCollapseColumn Visible="False" Resizable="False">

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</ExpandCollapseColumn>

 

 

<RowIndicatorColumn Visible="False">

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</RowIndicatorColumn>

 

 

</MasterTableView>

 

 

<ActiveItemStyle BackColor="White"></ActiveItemStyle>

 

 

<PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" />

 

 

</rad:RadGrid>

 



7 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 09 Feb 2009, 01:08 PM
Hello Das,

I could not reproduce the issue described so far. In my attempt to replicate the problem I created a test application. Please examine it and tell me if I am missing something from your logic.

Regards,
Georgi Krustev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Das
Top achievements
Rank 1
answered on 09 Feb 2009, 01:42 PM
Hello Georgi,

Thanks for your reply. The sample you have attached here is in RADGrid latest version. I am using RADAjax Classic(5.1.2.0) and RADAjaxManager (RADAjax 1.8.5.0). Thanks for your time.

0
Georgi Krustev
Telerik team
answered on 10 Feb 2009, 03:23 PM
Hi Das,

Unfortunately, I still cannot reproduce the problem described in this forum post. I have attached the updated with classic controls test project. You can review it and tell me whether I am missing something.

As far as how sorted items are based in grouped column, this is an expected behavior. When you group items by some column (apply group expression), it is normal to sort grouped items based on this expression.

Best regards,
Georgi Krustev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Das
Top achievements
Rank 1
answered on 18 Feb 2009, 08:50 AM
Sorry for the delay in response. I will explain the whole scenario of what I did. I have filtering., grouping and sorting enabled in the grid. The filtering should happen on pressing enter key. In order to accomplish this i have attached a script to trigger the filter process in the onkeypress event of the filter textboxes. Now when I do grouping and then press enter for filtering I am facing this issue. I am not sure how to add the code in this forum. I have added the sample code below.


OnItemCreated:


if (e.Item is GridFilteringItem)
            {
                GridFilteringItem filter = (GridFilteringItem)e.Item;
                for (int i = 0; i < rgDocuments.Columns.Count; i++)
                {
                    if (rgDocuments.Columns[i].ColumnType == "GridBoundColumn" || rgDocuments.Columns[i].ColumnType == "GridTemplateColumn")
                    {
                        if (filter[rgDocuments.Columns[i].UniqueName].Controls.Count > 0)
                        {
                            if (filter[rgDocuments.Columns[i].UniqueName].Controls[0].GetType().ToString().Contains("TextBox"))
                            {
                                TextBox tx = (TextBox)filter[rgDocuments.Columns[i].UniqueName].Controls[0];
                                //tx.Attributes["onkeypress"] = String.Format("if(window.event.keyCode == 13)__doPostBack('{0}','FilterOnEnterDocument:{1}:{2}');", rgDocuments.UniqueID, rgDocuments.Columns[i].UniqueName, rgDocuments.Columns[i].DataType.ToString());
                                tx.Attributes.Add("onkeypress", "if(FilterScript('" + rgDocuments.UniqueID + "','" + tx.ClientID + "','" + rgDocuments.Columns[i].UniqueName + "','" + rgDocuments.Columns[i].DataType.ToString() + "'))" + String.Format("__doPostBack('{0}','FilterOnEnterDocument:{1}:{2}');", rgDocuments.UniqueID, rgDocuments.Columns[i].UniqueName, rgDocuments.Columns[i].DataType.ToString()));
                            }
                        }
                    }
                }
            }



Page Load:

if

(eventArg.Split(':')[2].Contains("String"))

 

{

rgDocuments.MasterTableView.GetItems(

GridItemType.FilteringItem)[0].FireCommandEvent("Filter", new Pair("Contains", eventArg.Split(':')[1]));

 

}

 

else

 

{

rgDocuments.MasterTableView.GetItems(

GridItemType.FilteringItem)[0].FireCommandEvent("Filter", new Pair("EqualTo", eventArg.Split(':')[1]));

 

}

Please help me out on this. Thanks.

0
Das
Top achievements
Rank 1
answered on 19 Feb 2009, 05:27 AM
To add more information, the image button fires only for the first time on pressing enter key. The same happens if I have edit column in the grid with ButtonType Image. I tried to find the imagebutton in item databound event and block it on enter keypress using javascript but it was not working. This same issue happens to me in three grids. Hope you would be able to reproduce the issue. The only thing you should do is make the datagrid to filter on pressing enter key and you should be able to reproduce. Expecting a quick response. I am running out of time trying this. Please help me with this ASAP. Thanks.
0
Das
Top achievements
Rank 1
answered on 19 Feb 2009, 06:36 AM
Georgi,

Some more pointers to reproduce the issue in your project using Classic RAD Controls.

In the project you provided I made the following changes.

1) Remove the AutoPostbackonFilter = true. This works fine but I cannot refresh the grid on every lost focus.
2) Make the grid Ajax Enabled. This may be required.
3) Make the EditCommandColumn ButtonType as ImageButton.
4)Add the onkeypress event to the filter textboxes to filter on pressing enter key. This may or may not be required. If you are able to reproduce the issue with the above three then this should be fine.

If you notice the issue happens for the first time only and after that everything works fine. I know you are handling a lot of issues. But it would be great if you could get me some input ASAP or atleast an update so that I can provide some timeframe to resolve this issue. Thanks mate.

I have also posted another query regarding the filtering the template column with EditItemTemplate. The url is:
http://www.telerik.com/community/forums/aspnet-ajax/grid/filtering-templatecolumn-with-edititemtemplate-does-not-work.aspx

If possible check this one too. Thanks again.





0
Georgi Krustev
Telerik team
answered on 23 Feb 2009, 11:24 AM
Hello Das,

I reviewed your code snippet and everything looks fine. I modified my test project with your code in the attempt to reproduce this issue. Unfortunately, I could not notice any difference between the first and other filtering of the items. The groups will be sorted always according to the columns, which are used in the group expression.

Please find the attached file and let me know if I am missing something.

Regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Das
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Das
Top achievements
Rank 1
Share this question
or