Hi -
I have designed a custom form with Advanced filter/sort button (Label - Main Account Filter). Please take a look at the screen shot.
The Advanced filter/sort functionality works just fine. The Problem I'm having is that when I run the form the data is first populated on the grid and only then I can use the Advanced filter/sort button to filter the data. My question is that is there any way I can use the Advanced filter/sort before the data is populated on the form.
For example - I want the form to run and show no data on the grid. Then I can go and use Advanced filter/sort to filter and refresh the form to display the filtered data.
The reason I want to Implement this is because there will be a very large population of records that will be a part of this form. For speed/performance purposes, it would be good to be able to filter the population down before the query runs – rather than generating the full population of results and then filtering.
Is there a way I can implement this ?
Thank You for you help
*This post is locked for comments
Martin -
My bad your idea and code for DS init() works great ! I forgot to change the AutoSearch Property back to Yes for my DS. That's why the grid was always empty after selecting the criteria. It works fine now.
Thanks
Hello Martin -
Agreed - This seems a much better Idea to display the criteria first and then execute the form with data. I have added your piece of code in my init() of DS but I'm facing a minor problem which is that now the form opens up with no data but If only If I refresh the form (F5) it displays the data according to my Query Criteria. Is there a way I can add a code which will refresh my form automatically instead of the user manually refreshing the form ? I think it is Important to display the records on the form as soon as the criteria is selected instead of refreshing the form manually every time you open the form for the first time. what do you think ?
Thanks
I thought I would open the dialog from code, rather than letting users to click the button, because they can't use the form until they choose the criteria.
When I was preparing a sample code for you, I realized that it's not needed to disable AutoSearch and executing the query from code; we can simply show the dialog when initializing the form.
You could put the following code to init() method of your datasource.
public void init() { QueryRun qr; super(); qr = new QueryRun(this.query()); if (qr.prompt()) { this.query(qr.query()); } }
I found the solution on this issue. It was a reply from Martin on the other forum. here is the link to it.
dynamicsuser.net/.../populate-data-on-grid-launch
I added some code in forms init(), Run() and datasource executequery() method. The idea was to populate the grid with a record displaying values with 0. This way the Advance Filter/ Sort functionality will be visible on the form and ready to use. The user can then filter the records which will be displayed on the Grid.
public class FormRun extends ObjectRun
{
boolean started;
}
public void run()
{
super();
started = true;
}
public void executeQuery()
{
if (started)
{
table1_ds.queryBuildDataSource().clearRange(fieldNum(Table1, RecId));
table1_ds.queryRunQueryBuildDataSource().clearRange(fieldNum(Table1, RecId));
}
else
{
table1_ds.queryBuildDataSource().addRange(fieldNum(Table1, RecId)).value(queryValue(0));
}
super();
}
Martin Can you please give me some more details on this ? Thanks
Hi Martin -
OK now The first half of my problem is solved. Now the form opens up without any data after changing the Auto Search to No on a Datasource as you said.
But now my Advance Filter/Sort button is not working. (When I click on it no query window opens) I know you mentioned something about Executing the query from code. Can you please suggest a thread if there is any which will help me learn about "execute a query with code" ?
Thanks Again
You can set the data source with AutoSearch=No and execute the query from code when you're ready.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156