Friday 3 October 2014

LISTVIEWCONTROL IN DYNAMICS AX.

By using ListViewControl We have to see some functions,

1.How to select multiple records and shown from ListViewControl.

2.In ListViewControl how  to transfer multiple records from one  to another.

3.Inside the ListViewControl how to make Up and Down arrow Actions for that records.


Function 1:

Select Multiple records and shown in the infolog.

Step 1:

Create a new form(ListViewControl) and add the control ListView under Design node.



Step 2:

Change the properties for that control is Autodeclaration -->yes and viewtype-->report.



Step 3:

Mention the columns for that ListViewControl by using Init() method in form level,

public void init()
{

super();

LeftListView.addColumn(1, new FormListColumn("Customer AccountNumber"));

//LeftListView is Control Name.

}

Step 4:

Get the records from Somewhere.(Here I want to show all customer's account number. so I am taking
 records from custTable).

public void run()
{
CustTable custTable;
;
super();

// Adding items to the list
while select AccountNum from custTable
{
LeftListView.add(custTable.AccountNum);
}
}

Step 5:
Add a new button and put name as "selected records".Under this button write clicked() method for getting selected records in the infolog.

void clicked()
{
FormListItem item;
int i;
;

super();
i = LeftListView.getNextItem(FormListNext::Selected);
while (i != -1)
{
item = LeftListView.getItem(i);
info (item.text());
i = LeftListView.getNextItem(FormListNext::Selected,i);
}
}


Step 6:

       Now we complete the first function.




Function 2:

In ListViewControl how  to transfer multiple records from one  to another.

we have to follow some steps,,

Step 1:

Similar to first function put one more ListViewControl under design node.Set name as RightListView button.change the property as Autodeclaration-->yes and viewtype-->Report.

Step 2:

Add a new button and set name as MoveButton. Under this write clicked() method for transfer records from one control to another ListView, At the same time the transfer records should delete from first ListViewControl.

void clicked()
{
FormListItem item;
int i;
;

super();
i = LeftListView.getNextItem(FormListNext::Selected);
while (i != -1)
{
item = LeftListView.getItem(i);
RightListView.addItem(item);                      //Add items 
LeftListView.delete(i);      // Delete the selected item  from the LeftListView            i = LeftListView.getNextItem(FormListNext::Selected);
}
}

Step 3:

Now we complete the second function.




Function 3:

Inside the ListViewControl how to make Up and Down arrow Actions for that records.

Step 1:

Add two more buttons in the form.Set name as "ÜpButton" and "DownButton".Write the single line code for that buttons under clicked() method.

Code for move the item Upwards,

void clicked()
{
int i = LeftListView.getNextItem(FormListNext::Selected); 

LeftListView.moveItem(i, i-1);





Code for move the items Downwards,

void clicked()
{
int i = LeftListView.getNextItem(FormListNext::Selected); 

LeftListView.moveItem(i, i+1);





Step 2:

       We complete the third function also.



No comments:

Post a Comment