Infragistics WebDataGrid - need to set filter at runtime in VB code behind form

I am using the new WebDataGrid (V9.2.20092.2014) using VS2008  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>

                                    <ig:BoundDataField DataFieldName="Shift" Key="Shift" Width="80px">

                                        <Header Text="Shift" />

                                    </ig:BoundDataField>

                                    <ig:BoundDataField DataFieldName="Schedule" Key="Schedule" Width="80px">

                                        <Header Text="Schedule" />

                                    </ig:BoundDataField>

                                    <ig:BoundDataField DataFieldName="JobOpeningType" Key="JobOpeningType" Width="80px">

                                        <Header Text="Job Type" />

                                    </ig:BoundDataField>

                                    <ig:BoundDataField DataFieldName="City" Key="City" Width="100px">

                                        <Header Text="City" />

                                    </ig:BoundDataField>

                                    <ig:BoundDataField DataFieldName="StateAbbrev" Key="StateAbbrev" Width="35px">

                                        <Header Text="State" />

                                    </ig:BoundDataField>

                                    <ig:BoundDataField DataFieldName="Pay" Hidden="True" Key="Pay">

                                        <Header Text="Pay" />

                                    </ig:BoundDataField>

                                    <ig:BoundDataField DataFieldName="intJobId" Hidden="True" Key="intJobId" Width="35px">

                                        <Header Text="Job ID" />

                                    </ig:BoundDataField>

                                    <ig:TemplateDataField Key="JobDetails" CssClass="table-link">

                                        <ItemTemplate>

                                            Details

                                        </ItemTemplate>

                                        <Header Text="Details" />

                                    </ig:TemplateDataField>

                                </Columns>

                                <AjaxIndicator Enabled="True" ImageUrl="/ig_res/rtt/images/ig_progressIndicator.gif"

                                    Location="TopLeft" />

                            </ig:webdatagrid>

 
<asp:SqlDataSource ID="dataJobs" runat="server" ConnectionString="<%$ ConnectionStrings:AlexisConnectionString %>"
SelectCommand="usp_JobBoard_GetJobs" SelectCommandType="StoredProcedure" EnableCaching="True" CacheDuration="Infinite" > 
<SelectParameters>
<asp:SessionParameter DefaultValue="** Not Selected **" Name="Profession" SessionField="Profession" />
<asp:SessionParameter DefaultValue="'**'" Name="State" SessionField="StateAbbrev" />
<asp:SessionParameter DefaultValue="'** Not Selected **'" Name="JobType" SessionField="JobOpeningType" />
<asp:SessionParameter DefaultValue="'** Not Selected **'" Name="Setting" SessionField="Setting" />
<asp:Parameter DefaultValue="0" Name="JobRanking" Type="Int32" />
<asp:SessionParameter DefaultValue="1" Name="PageNumber" SessionField="pageCurrent"
Type="Int32" />
<asp:Parameter DefaultValue="99999" Name="JobsPerPage" Type="Int32" />
<asp:SessionParameter DefaultValue="strStateAbbrev" Name="SortBy" SessionField="SortBy"
Type="String" />
<asp:Parameter DefaultValue="2" Name="OverrideType" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
Default.aspx.txt
CaptBuzzAsked:
Who is Participating?
 
CaptBuzzConnect With a Mentor Author Commented:
I received an answer from the Infragistics forum:

Here is the example code of how you can do this from code behind:
 Dim filtering As Filtering
filtering = 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 dataBinds
filtering.ApplyFilter()
0
 
Bob LearnedCommented:
I don't have the new UltraWebGrid (still using 2007 version)...

Are you saying that you can't figure out the filtering?  Since you are using an SqlDataSource, it has FilterExpression property.

SqlDataSource.FilterExpression Property
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.filterexpression.aspx
0
 
CaptBuzzAuthor Commented:
I can do that & have it working. I would like to make one trip to the database, then do all filtering/sorting/paging on the webdatagrid.
0
 
Bob LearnedCommented:
I have never been a big fan of the complexity that Infragistics brings to its controls.  I would think that it would be easier to sort and filter the WebDataGrid with a DataView with the Sort and RowFilter properties set.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.