[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2009-12-17
4
Medium Priority
?
6,277 Views
Last Modified: 2013-11-15
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
0
Comment
Question by:CaptBuzz
  • 2
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 26081427
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
 

Author Comment

by:CaptBuzz
ID: 26081441
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 26082195
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
 

Accepted Solution

by:
CaptBuzz earned 0 total points
ID: 26083362
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month17 days, 18 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question