I am using the new WebDataGrid (V9.2.20092.2014) and I can figure out how to filter data at runtime. I want to allow the user to make some selections using dropdowns then apply a filter to the data when the user clicks a button. I can't figure out what I need to do in my VB code behind form. I thought it would be something like:
Me.grdJobs.Behaviors.Filtering.ColumnFilters.Item("Profession").Condition = "Equals 'PTA'"
Me.grdJobs.Behaviors.Filtering.ApplyFilter()
but the first line above gives an error.
The filtering works when I click the filter icon on the grid, select "equals","contains", etc, enter a value and hit enter but that's not what I want.
Sample code would be GREATLY appreciate. I've banged my head on the desk enough...
<ig:webdatagrid id="grdJobs" runat="server" width="650px"
enabledataviewstate="True" stylesetname="RTT" autogeneratecolumns="False"
datakeyfields="intJobId" ajaxindicator-enabled="true"
DataSourceID="dataJobs">
<Behaviors>
<ig:Paging PagerAppearance="Both" PagerMode="NumericFirstLast" QuickPages="3" PageSize="25"
FirstPageText="First" LastPageText="Last">
</ig:Paging>
<ig:Sorting>
</ig:Sorting>
<ig:Filtering>
<ColumnFilters>
<ig:ColumnFilter ColumnKey="Profession">
<ConditionWrapper>
<ig:RuleTextNode Value="Equals COTA" />
</ConditionWrapper>
</ig:ColumnFilter>
</ColumnFilters>
</ig:Filtering>
</Behaviors>
<Columns>
<ig:TemplateDataField Key="AddToCart" Width="75px" CssClass="table-link">
<ItemTemplate>
Add To Cart
</ItemTemplate>
<Header Text="Add To Cart" />
</ig:TemplateDataField>
<ig:BoundDataField DataFieldName="Profession" Key="Profession" Width="70px">
<Header Text="Profession" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Skill" Key="Skill" Width="80px">
<Header Text="Skill" />
<ig:BoundDataField DataFieldName="Shift" Key="Shift" Width="80px">
<Header Text="Shift" />
<ig:BoundDataField DataFieldName="Schedule" Key="Schedule" Width="80px">
<Header Text="Schedule" />
<ig:BoundDataField DataFieldName="JobOpeningType" Key="JobOpeningType" Width="80px">
<Header Text="Job Type" />
<ig:BoundDataField DataFieldName="City" Key="City" Width="100px">
<Header Text="City" />
<ig:BoundDataField DataFieldName="StateAbbrev" Key="StateAbbrev" Width="35px">
<Header Text="State" />
<ig:BoundDataField DataFieldName="Pay" Hidden="True" Key="Pay">
<Header Text="Pay" />
<ig:BoundDataField DataFieldName="intJobId" Hidden="True" Key="intJobId" Width="35px">
<Header Text="Job ID" />
<ig:TemplateDataField Key="JobDetails" CssClass="table-link">
Details
<Header Text="Details" />
</Columns>
<AjaxIndicator Enabled="True" ImageUrl="/ig_res/rtt/images/ig_progressIndicator.gif"
Location="TopLeft" />
</ig:webdatagrid>
Hi,
Here is the example code of how you can do this from code behind:
Dim filtering As Filteringfiltering = WebDataGrid1.Behaviors.Filtering
Dim columnFilter As ColumnFilter
columnFilter = New ColumnFilter()columnFilter.ColumnKey = "Country"' Depending on the column type you would use a different type of rule ' (such as RuleNumberNode, RuleDateNode, RuleBoolNode)columnFilter.Condition = New RuleTextNode(TextFilterRules.Equals, "Mexico")
filtering.ColumnFilters.Add(columnFilter)
' You can call this to have the filter condition apply right away, otherwise it ' will be applied the next time the grid dataBindsfiltering.ApplyFilter()
Thanks,Olga
Olga,
Is there a way I can just get the filters of the WebDataGrid? I just need to get the entire filter (multiple column filters) string of the grid so I can pass it to my crystal Reports for printing. All I need is the filter string.
thanks
klp0
Unfortunately, the grid does not give you a way to get the actual filter string. This string gets build out from the ColumnFilters and it actually would be different depending on which datasource the grid is bound to.
Thank You,
Olga
I am using this code but i found an issue like infinite loop and if i apply the multiple filters to the multiple column then how it works
code snipete :
Private Sub WebDataGrid1_DataFiltering(ByVal sender As Object, ByVal e As Infragistics.Web.UI.GridControls.FilteringEventArgs) Handles WebDataGrid1.DataFiltering
'Dim cf As GridControls.ColumnFilter
Dim y As String
Dim filtering As Filtering filtering = WebDataGrid1.Behaviors.Filtering
columnFilter = New ColumnFilter()
For Each columnFilter In e.ColumnFilters
y = columnFilter.Condition.GetFilterRuleString(columnFilter.ColumnKey) columnFilter.ColumnKey = columnFilter.ColumnKey
If columnFilter.ColumnType = "String" Then columnFilter.Condition = New RuleTextNode(TextFilterRules.Equals, y) End If
Next filtering.ColumnFilters.Add(columnFilter) filtering.ApplyFilter() Exit Sub
End Sub
if i use the date column in infragistics web data grid then filter dropdown displays an option such as Tommoro,yesterday etc,if i filtered with Tommoro then i need to show "Tommoro" this string into the filter text box
Thanks
Ganesh