I am using radgird and allowing filters on all columns. I have 3 columns on grid and I am binding those columns dynamically using vb.net code behind.
On UI page I have only the below script:
<telerik:RadGrid ID="gridData" runat="server" Visible="true" RenderMode="Native"> </telerik:RadGrid>
The problem is that when I apply filter on one column that is worked fine now simultaneously I apply filter on second column then it removes the filter of first column. Please see the attached screenshot.
In code behind I have grid event like:
Protected Sub gridData_NeedDataSource(ByVal Source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles gridData.NeedDataSource
but this event is also not firing in any case.
Any idea about filtering on multiple columns issue?
8 Answers, 1 is accepted
In the documentation it is stated:
"As many of the controls, especially RadGrid, are complex controls which do not have such specific HTML element equivalents, the Native render mode is not supported or have the same effect as Classic."
You can check the full explanation here:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/mobile-support/render-modes
Please change the RenderMode of the grid and let me know if it resolves the issue.Performing complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, Grouping, Exporting, Paging, Sorting, Filtering, etc. require accommodating appropriate database operations. Therefore, we suggest you to avoid Simple Databinding and strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions:
Declarative DataSource (DataSourceID property)
Programmatic Data Binding (NeedDataSource event, + DetailTableDataBind for hierarchy). You should set the DataSource property ONLY within these event handler.
Also, temporarily disable any AJAX on the page if present (RadAjaxManager, RadAjaxPanel, UpdatePanel, etc.) and enable your script debugger (FireBug or F12) to see whether there are any script or server errors interfering.
Regards,
Eyup
Telerik
Filtering in radgrid does not work when sysid is the first column and sysdttm is the second column. It works when I swap them. I made sysdttm first column and sysid as the second column it works. The code below works. I was wondering why it doesn't work other way around.
Thank you.
ASPX:
<telerik:RadGrid ID="rgInbq" AllowAutomaticUpdates="false" AutoGenerateColumns="false" AllowSorting="TRUE" ShowHeaderWhenEmpty="true" EnableEmbeddedskins="True" GridLines="None"
runat="server" Skin="Black" ShowFooter="True" Width="100%" AllowPaging="True" pagesize ="50" AllowFilteringByColumn="True" EnableLinqExpressions="false"
OnNeedDataSource="rgInbq_NeedDataSource" >
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Black">
</HeaderContextMenu>
<ClientSettings AllowColumnsReorder="True" EnableRowHoverStyle="True" >
<Scrolling UseStaticHeaders="True" ScrollHeight="600px" AllowScroll="true"></Scrolling>
<Selecting AllowRowSelect="True" />
</ClientSettings>
<MasterTableView DataKeyNames="SYS_ID, STATUS, TRAILER_ID, LOC_ID" AutoGenerateColumns="False" >
<EditFormSettings>
<EditColumn CancelImageUrl="Cancel.gif" EditImageUrl="Edit.gif" InsertImageUrl="Update.gif" UpdateImageUrl="Update.gif">
</EditColumn>
</EditFormSettings>
<Columns>
<telerik:GridBoundColumn DataField="SYS_DT_TM" HeaderText="IB DATE TIME" ReadOnly="true" SortExpression="SYS_DT_TM" UniqueName="SYS_DT_TM" AllowFiltering="false" >
<HeaderStyle Font-Size="8pt" width="20px"/>
<ItemStyle Font-Size="10pt" HorizontalAlign="LEFT" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="SYS_ID" HeaderText="INBQ REF" ReadOnly="true" SortExpression="SYS_ID" UniqueName="SYS_ID" AllowFiltering="true" AutoPostBackOnFilter="true" ShowFilterIcon="false" FilterControlWidth="70px" Aggregate="Count" CurrentFilterFunction="Contains" >
<HeaderStyle Font-Size="8pt" Width="20px"/>
<ItemStyle Font-Size="10pt" HorizontalAlign="LEFT"/>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="USER_ID" HeaderText="USER ID" ReadOnly="true" SortExpression="USER_ID" UniqueName="USER_ID" AllowFiltering="false" >
<HeaderStyle Font-Size="8pt" width="10px"/>
<ItemStyle Font-Size="10pt" HorizontalAlign="LEFT" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="LOC_ID" HeaderText="LOC ID" ReadOnly="true" SortExpression="LOC_ID" UniqueName="LOC_ID" AllowFiltering="false" >
<HeaderStyle Font-Size="8pt" Width="10px" />
<ItemStyle Font-Size="10pt" HorizontalAlign="LEFT" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="TRAILER_ID" HeaderText="TRAILER ID" ReadOnly="true" SortExpression="TRAILER_ID" UniqueName="TRAILER_ID" AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" FilterControlWidth="100px">
<HeaderStyle Font-Size="8pt" Width="20px" />
<ItemStyle Font-Size="10pt" HorizontalAlign="LEFT" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="STATUS" HeaderText="STATUS" ReadOnly="true" SortExpression="STATUS" UniqueName="STATUS" AllowFiltering="false" >
<HeaderStyle Font-Size="8pt" Width="10px" />
<ItemStyle Font-Size="10pt" HorizontalAlign="LEFT" />
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn UniqueName="UPDATE" HeaderText="UPDATE STATUS TO SUS" Visible="TRUE" AllowFiltering="false">
<ItemTemplate>
<asp:imageButton ButtonType="ImageButton" ID="btnUpdate" runat="server" CommandName="UPDATE" ImageUrl="images/Update.gif" OnClientClick="return confirm('Are you certain you want to UPDATE the status to SUS?');"
Text="Update" />
</ItemTemplate>
<HeaderStyle ForeColor="WHITE" HorizontalAlign="left" Width="100px" />
<ItemStyle />
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
The filtering of the SYS_ID column should work in both of the cases, while the filtering of the SYS_DT_TM column will work if you enable its AllowFiltering property. You can also check your rgInbq_NeedDataSource logic in the code-behind and ensure that it does not include DataBind or Rebind methods inside:
https://www.telerik.com/support/kb/aspnet-ajax/grid/details/how-to-bind-radgrid-properly-on-server-side
If the issue remains, please open a formal support thread and send us a very basic isolated runnable web site to demonstrate the issue for further investigation.
Regards,
Eyup
Progress Telerik
I don't want the filtering on the sys dt tm column. Filtering the sys id column is needed though. I don't know why now the filtering doesn't work if sys id is placed in the first column or the second column. There is no data bind or rebind in the need data source. :\
Protected Sub rgInbq_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs) Handles rgInbq.NeedDataSource
Dim ds As DataSet
Dim MyCommand As SqlDataAdapter
Dim nRecCount As Integer
Dim dt As DataTable
'CheckSystem()
'strUserID = Session("USERID")
strSQlData = "SELECT SYS_ID, SYS_DT_TM, USER_ID, LOC_ID, TRAILER_ID, STATUS FROM INBOUND_Q WHERE STATUS = 'WIP'"
MyCommand = New SqlDataAdapter(strSQlData, oConn)
ds = New DataSet
MyCommand.Fill(ds, "INFO")
'Assign Values For text fields
dt = ds.Tables(0)
Dim Source As DataView = ds.Tables("INFO").DefaultView
If dt.Rows.Count > 0 Then ' Verify If a Contact Exists
nRecCount = dt.Rows.Count
rgInbq.DataSource = Source
'rgInbq.DataBind()
rgInbq.Visible = True
oConn.Close()
Else
rgInbq.DataSource = Source
'rgInbq.DataBind()
rgInbq.Visible = True
oConn.Close()
End If
End Sub
In this case, it would be better if we reproduce the issue locally on our side in order to further debug it. Please open an official support ticket and modify the attached web site sample to demonstrate the issue and send it back to us.
Regards,
Eyup
Progress Telerik
Hi Sayali,
In order to be able to help we would need more information on the current structure/configuration of the Grid you are working on.
In general enabling filtering for the columns is a straight-forward procedure by enabling a single property. Filtering will work on all columns.
See the following example:
<script runat="server">
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
(sender as RadGrid).DataSource = Enumerable.Range(1,10).Select(x=> new { ID = x, Description = "Description "+x });
}
</script>
<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="true" OnNeedDataSource="RadGrid1_NeedDataSource">
</telerik:RadGrid>
If they do not work as expected, there must be something in the implementation that prevents that. Please share more details so we can see what is happening with the grid and we'll advise you accordingly.
Kind regards,
Attila Antal
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.