How to Display All TableName in ListBox and Create Filter in Ax 2012

Description:- In this Example we will see how to bind all tables name from AOT which is coming from database and user filter can we provide for searching tables in that list box.

Step 1: Now Create Form and Name it “BindAllTableForm”. And Add List box and StringEdit Controls in Design Node.
  • Expand AOT Node.
  • Select Form Node and Right Click Select New Form and Name it “BindAllTableForm”.
  • Now Drag and Drop Table in Form DataSource.
  • Select Design Node Right Click and Select New Controls & Add Grid Controls in Design Node.
Step 2: Now generate Form init Method.
  • Expand Form.
  • Select Method and right click and select init Method.

Now Code for Bind all tables when Form call first time. Or else you can Create New Method by right clicking on Form Method node. And code here. Here we will pass parameter for filter values based on StringEdit Controls values.

void initTables(str 40 strFilter)
{
    SqlDictionary sqlDictionary;
    ;
    Listbox.clear();
    // Add in the listbox all Axapta tables
    while select Name from sqlDictionary 
    order by Name
    where sqlDictionary.FieldId==0 && sqlDictionary.Name like strFilter+'*'
    {
        Listbox.add(sqlDictionary.Name);
    }
}

Now Call Created Method in Form init Method like below.

public void init()
{
    super();
    element.initTables('*');
}

Step 3: Now Generate “textChange” Method of StringEdit Control by right click of Method node of that Control and Select from Override method. And Call Created Method and pass as user input values in parameter like below.


public void textChange()
{
    super();
    element.initTables(tableName.text());
}

Now run your form and you can check all tables are in Listbox. Now input value in StringEdit and filter values.



Related Posts

Previous
Next Post »

Thanks for comments.....