Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Sunday, July 6, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Web Forums - SalesLogix Web Platform & Application Architect
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Web Platform & Application Architect | New ThreadView:  Search:  
 Author  Thread: Is it possible to Filter a Data Grid at run time?
Alec Denholm
Posts: 23
 
Is it possible to Filter a Data Grid at run time?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Oct 08 9:16 AM
Hi,

I have the requirement to make two filter-dependent grids at run time. I'm afraid I have no idea how I'd achieve this.

Scenario 1 is a Data Grid tab at Opportunity level showing other Opportunities at the same Account (this is the easy bit), with the addition of some filters (on Reseller, Status etc) - this is the part I'm struggling with. In the LAN, it's simply a case of building a SQL string according to the filter values and applying it to the Data Grid. How can I emulate this behaviour in the Web?

Scenario 2 is also a Data Grid tab, only this one holds two grids side by side; the 'child' grid updates to show detail based on a selected row in the 'parent' grid. Although a different concept, I think it's still a case of a user-triggered event causes the 'SQL' of the grids to update, subsequently effecting the data displayed.

I've heard mention of something called NHibernate, could this (or the ExpressionFactory built on it) be used to dynamically update grid SQL at run-time? Or is my head in the clouds...
As always I appreciate any help which can be offered!

- Al
[Reply][Quote]
Alberto Chiesa
Posts: 49
 
Re: Is it possible to Filter a Data Grid at run time?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Oct 08 11:17 AM
I have exactly the same issue as in Scenario 1! I can't figure out how to "parameterize" the query with unbounded field values.

About scenario 2:
I don't know of any way to obtain what you're requesting, but a possible solution is to split the form in 2.

The main form will hold the main grid. The detail form will hold the detail grid.

You can use a "Edit" field in the main form to trigger the opening of the detail form in the dialog workspace.

If you can't figure out how to obtain this I can give you some advice (I'm no expert but I managed to get this working).

[Reply][Quote]
Stephen Redmond
Posts: 190
 
Re: Is it possible to Filter a Data Grid at run time?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Oct 08 1:31 PM
Here is your "starter" - thanks to Mr. R. Farley:

http://customerfx.com/pages/crmdeveloper/2008/05/22/creating-a-business-rule-to-return-a-list-of-objects.aspx

Now, to the other item. I haven't done that one myself, but, in theory, this is what I would do. There is a "Select" type of field that you can add to a data grid. It selects the row and fires an event. You will be able to code the event to load your second data grid using the same method as above.

Let me know how you get on.



Stephen
www.slxmaster.com
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Is it possible to Filter a Data Grid at run time?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Oct 08 2:23 PM
You definitely can do this. You'll create a business rule that gathers the data you need (Stephen already linked to a good article for that ). You can set up the rule to include any params you want to pass in.

As far as binding that to a grid, you'll do that in a LoadAction (with repaint event = true). Keep in mind that the SLX grid is just a subclassed standard ASP.NET GridView. So, you can easily bind an List of objects (returned from a business rule). You just set it as the DataSource and then call DataBind as you'd expect normally.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Is it possible to Filter a Data Grid at run time?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Oct 08 2:40 PM
As far as scenario #2 is concerned, other than the alternative idea that Alberto mentioned, you won't be able to do this as a QuickForm, you'll need to do this as a custom SmartPart, but it is doable.
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: Is it possible to Filter a Data Grid at run time?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Oct 08 3:34 AM
Quote:
Originally posted by Alec Denholm

Hi,

I have the requirement to make two filter-dependent grids at run time. I'm afraid I have no idea how I'd achieve this.

Scenario 1 is a Data Grid tab at Opportunity level showing other Opportunities at the same Account (this is the easy bit), with the addition of some filters (on Reseller, Status etc) - this is the part I'm struggling with. In the LAN, it's simply a case of building a SQL string according to the filter values and applying it to the Data Grid. How can I emulate this behaviour in the Web?

Scenario 2 is also a Data Grid tab, only this one holds two grids side by side; the 'child' grid updates to show detail based on a selected row in the 'parent' grid. Although a different concept, I think it's still a case of a user-triggered event causes the 'SQL' of the grids to update, subsequently effecting the data displayed.

I've heard mention of something called NHibernate, could this (or the ExpressionFactory built on it) be used to dynamically update grid SQL at run-time? Or is my head in the clouds...
As always I appreciate any help which can be offered!

- Al


Scenarios 1) Using good old sql... This is possible in a quickform (I think!)...although you do have to cheat slightly. On a quickform loadaction (ensure it is a refresh event..) put your code in that you want to run, then finish with a }. You can now add your own constants that will remain on the screen. So the code for the loadaction will look like:

blah.Account = "test"; //just some random code you want to run onload...

} //end the quick form load

//Set up a sql datasource for your datagrid.

SqlDataSource dsMyDataSource = new SqlDataSource();

protected void Page_PreRender()
{
Sage.Platform.Data.IDataService service = Sage.Platform.Application.ApplicationContext.Current.Services.Get();
string constr = service.GetConnectionString();
string sql;
dsMyDataSource.ProviderName = "System.Data.OleDb";
dsMyDataSource.ConnectionString = constr;
string someWhereClause = "YOUR WHERE CLAUSE ETC.."
sql = "select a.accountid, a.accountid as id, a.accountid as InstanceId, a.account, ad.country as country, a.mainphone as phone, a.status, u.firstname + ' ' + u.lastname as accountmanager from account a left join userinfo u on a.accountmanagerid = u.userid inner join address ad on a.addressid = ad.addressid where " + someWhereClause() + " like '" + txtValueAccount.Text + "%'";
dsMyDataSource.SelectCommand = sql;

yourDataGrid.DataSource = dsMyDataSource;
yourDataGrid.DataBind();

The important things to remember here is that the datagrid needs an InstanceId, an Id and columns to have the same names as the datagrid specified. So these need to be in your sql. To see what they need, build the quickform as normal without all this stuff and look at the resulting ascx when it is in Inetpub...slxclient\smartparts etc. For example you can see my grid has:

<#ItemTemplate>
<%# Eval("#account") %>
<#/ItemTemplate>
Oh slxdeveloper has wiped it out...

it is basically some itemtemplate fields looking for a value named account, so this is what my sql must return..

So my sql needs to have a column named account, so it can bind.

Also do NOT put an end curly bracket on - SLX will do this for you....

Now, admittedly I have the above working in a custom smartpart but it could work in a quickform I believe. Give it a go! Or of course you could go the NHibernate route using Ryan's extremely useful article. It is nice to use a bit of good old sql from time to time though

And sorting...does you grid need sorting? Hopefully not or you probably will need a custom smartpart.

For scenario 2) defintely rip out the quickform and make it a custom smart part. That way you can modify the select event for the first grid (the events are setup in the datagrid header ie. OnRowCommand="AssociateAccount_RowCommand" - you can edit this specified method to refresh your other grid. You can use the same idea though of having a sql datasource, set the provider and the sql, add it to the other datagrid and bind the grid.

Let me know how you get on...

Cheers,
Nick

[Reply][Quote]
Alberto Chiesa
Posts: 49
 
Re: Is it possible to Filter a Data Grid at run time?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Oct 08 5:38 AM
Quote:
Originally posted by Ryan Farley

You definitely can do this. You'll create a business rule that gathers the data you need (Stephen already linked to a good article for that ). You can set up the rule to include any params you want to pass in.

As far as binding that to a grid, you'll do that in a LoadAction (with repaint event = true). Keep in mind that the SLX grid is just a subclassed standard ASP.NET GridView. So, you can easily bind an List of objects (returned from a business rule). You just set it as the DataSource and then call DataBind as you'd expect normally.


Thanks Ryan!

You saved my day!

Something like this on the onLoad of the form works like a charm:


Sage.Entity.Interfaces.IContact contact = (Sage.Entity.Interfaces.IContact) this.GetParentEntity();

System.Collections.Generic.List<Sage.Entity.Interfaces.IYourEntity> recordToList =
(System.Collections.Generic.List<Sage.Entity.Interfaces.IYourEntity> ) contact.CustomBusinessRule(additional parameters);

QFDataGrid.DataSource = recordToList;
QFDataGrid.DataBind();


Using the values loaded from the form fields as the additional parameters did the trick!

Thanks!
[Reply][Quote]
Tom Smith
Posts: 13
 
Re: Is it possible to Filter a Data Grid at run time?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Jun 09 2:34 AM
I am trying to do this on an entity-less form (custom lookup)

1. I added the business rule at the Account entity (see code below), added an entity-less form and a button to show it.

2. Trying to bind the grid, but the DataSource "Source" property blanks out whenever I set it to Account?
Is this not possible at an entity-less form? Or is there a different way to do it?

3. I tried deploying it anyway, but I get this error "c:\Inetpub\wwwroot\SlxClient\SmartParts\CustomSearch.ascx(424): error CS0115: 'ASP.CustomSearch.OnFormBound()': no suitable method found to override"

This is my code for the Business Rule...really basic for now.
---------------------------------------------------------------------
IRepository repository = EntityFactory.GetRepository();
IQueryable qry = (IQueryable)repository;
IExpressionFactory ef = qry.GetExpressionFactory();

ICriteria criteria = qry.CreateCriteria();
if (Name == "")
{
criteria.Add(ef.Like("Account","A%"));
}
else
{
criteria.Add(ef.Like("Account", Name + "%"));
}
result = criteria.List();
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Is it possible to Filter a Data Grid at run time?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Jun 09 12:48 PM
The error message you are getting is indeed because of the Form Type you are using.
Since it is "Entiy Less", it doesn't bind, and it doesn't have an "OnFormBound" method, thus you can't overwrite it.

Try to override a different method, you may just have to rely on Page_Load.
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 7/6/2025 7:11:52 AM