如何在动态中创建动态过滤器

How to create a dynamic filter in dynamics

我需要为名称列创建动态筛选。此过滤器需要为用户键入的每个字符自动刷新我的数据。它应该显示包含用户值的数据。

这是我的代码。我现在该怎么办?

    [DataSource]
class dbContacts
{
    /// <summary>
    ///
    /// </summary>
    public void init()
    {
        super();

        queryFilter = dbContacts_ds.query().addQueryFilter(dbContacts_ds.queryBuildDataSource(),"SNazwa");
    }

    /// <summary>
    ///
    /// </summary>
    public void executeQuery()
    {
        queryFilter.value(element.design().controlName("FormStringControl1").valueStr());

        super();

    }

    [DataField]
    class SNazwa 
    {
        /// <summary>
        ///
        /// </summary>
        /// <param name = "_formControl"></param>
        /// <param name = "_filterStr"></param>
        public void lookup(FormControl _formControl, str _filterStr)
        {

            super(_formControl, _filterStr);

            queryFilter = dbContacts_ds.query().addQueryFilter(dbContacts_ds.queryBuildDataSource(),"SNazwa");
        }
    [Control("String")]
class FormStringControl1
{
    /// <summary>
    ///
    /// </summary>
    /// <returns></returns>
    public boolean modified()
    {
        boolean ret;

        ret = super();

        dbContacts_ds.executeQuery();

        return ret;
    }

这就是我实现它的方式并且它有效(基于 Creating custom instant search filters in Ax 2009 and 2012):

[Form]
public class FormContacts extends FormRun
{   
    QueryFilter queryFilter;
    FormStringControl FormStringControl1;

[DataSource]
class dbContacts
{
    public void init()
    {
        super();
        queryFilter = dbContacts_ds.query().addQueryFilter(dbContacts_ds.queryBuildDataSource(),"SNazwa");
    }

    public void executeQuery()
    {
        queryFilter.value("*"+element.design().controlName("FormStringControl1").valueStr()+"*");
        super();
    }
}

[Control("String")]
class FormStringControl1
{
    public boolean modified()
    {
        boolean ret;
        str nameFilter;
        ret = super();

        nameFilter = '*'+this.text()+'*';
        dbContacts_ds.filter(fieldnum(dbContacts,SNazwa),nameFilter);

        dbContacts_ds.executeQuery();

        return ret;
    }

    public void textChange()
    {
        super();
        this.modified();
    }

    public void enter()
    {
        super();
        this.setSelection(strlen(this.text()),strlen(this.text()));
    }
}

[Control("String")]
class dbContacts_SNazwa
{
    protected void initialize()
    {
        super();
    }
}

}