Populate Data on Grid Launch

Okay, I’m probably just not using the right search text to find an answer for this, but I have a grid in a form that is tied to a data source that is rather large. All I’m looking for is a way to launch the form so the grid is blank (data not populated from the data source) so it doesn’t take time to load with the data. The user can then enter grid filters to limit the amount of data returned and refresh the grid with the filtered data from the data source.

I hope that makes sense. I would think they would have included a grid property or something I could add to the init method to prevent it from loading the data when the grid is initially launched. Whenever I try to find a solution, I get info about people having problems with their grid not populating with their data, whereas I’m intentionally trying to launch the grid form without data (only when the form is first opened though)…like a ‘populate data on init’ option.

Thanks for any help!

Open properties of the data source and change AutoSearch to No.

Thank you so much! I knew there had to be a simple solution, I just couldn’t find it.

Argh! This creates a new problem…my ‘filter by grid’ option is grayed out now when I launch the form.

I don’t think that your original requirement is compatible with Filter by grid. I thought you would use Advanced Filter/Sort or custom controls.

Nevertheless you can do some little hacks, if you’re creative.

For example, let’s say that you execute the query when opening the form (so you’ll get Filter by grid), but you’ll use such a filter that it returns no data (you could even disable some data sources). When user executes the query again (e.g. by using Filter by grid), you have to remove your filter, otherwise you wouldn’t return anything. It might look like this:

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();
}

That is actually the direction I was heading before posting this, but I was stuck with the problem of my filter value displaying in the grid filter row and wasn’t sure how to clear it. Let me play with your code and see if I can get it to work. Thanks!