AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 05.02.2008, 17:25   #1  
Blog bot is offline
Blog bot
Участник
 
25,584 / 848 (80) +++++++
Регистрация: 28.10.2006
axaptapedia: Multi Column
Источник: http://www.axaptapedia.com/Multi_Column
==============

Summary: /* Report */
== Data Structure ==

This is tutorial how to create multiple columns on a report. The report designer has no support for multi column rendering; Like in Word where you can set a "Number of Columns" property on a paragraph. As Workaround create a temporary table with exactly the same fields as needed on the report. For example if you want to display SalesId, CustAccount, ItemId and Qty from the SalesLine, the temporary table for two columns has 8 columns.

[[Image:TmpSalesTable2Col.PNG]]

The getFreeSlot() Method is needed in the report to determine if there is a free column slot or if it is necessary to create a new line on the table.

public static TmpSalesTable2Col getFreeSlot(TmpSalesTable2Col tmp,int column)
{
;

if(column==1)
{
select firstonly tmp where tmp.SalesId_1 == "";
return tmp;
}
else if(column==2)
{
select firstonly tmp where tmp.SalesId_2 == "";
return tmp;
}
else
{
throw error("Column number must be between 0 and 1");
}
}


== Report ==

Create a new report and declare a variable from type of the temporary table.

public class ReportRun extends ObjectRun
{
TmpSalesTable2Col tmpSalesTable;
}


Create a new method to populate the temporary table. In this example the SalesLine is fetched. If it was created in 2007 it belongs to column number 1 and if it was created in 2008 it belongs to column number 2. I assume here that there are only rows for 2007 or 2008. Otherwise it would be good to filter the select by year. The find() method is used to find a free slot; That means a record exists but with a free slot for the needed column.

private void populateTmpTable()
{
SalesLine salesLine;
TmpSalesTable2Col temp;
int col;
;

while select salesLine
order by SalesId
{
// 2007 is first column
if(year(salesLine.createdDate)==2007)
{
temp = TmpSalesTable2Col::getFreeSlot(tmpSalesTable,1);
// existing record with free slot in first column
if(temp)
{
temp.SalesId_1 = salesLine.SalesId;
temp.ItemId_1 = salesLine.ItemId;
temp.CustAccount_1 = salesLine.CustAccount;
temp.Qty_1 = salesLine.QtyOrdered;
temp.update();
}
else
{
tmpSalesTable.clear();
tmpSalesTable.SalesId_1 = salesLine.SalesId;
tmpSalesTable.ItemId_1 = salesLine.ItemId;
tmpSalesTable.CustAccount_1 = salesLine.CustAccount;
tmpSalesTable.Qty_1 = salesLine.QtyOrdered;
tmpSalesTable.insert();
}
}
// 2008 is second column
if(year(salesLine.createdDate)==2008)
{
temp = TmpSalesTable2Col::getFreeSlot(tmpSalesTable,2);
// existing record with free slot in second column
if(temp)
{
temp.SalesId_2 = salesLine.SalesId;
temp.ItemId_2 = salesLine.ItemId;
temp.CustAccount_2 = salesLine.CustAccount;
temp.Qty_2 = salesLine.QtyOrdered;
temp.update();
}
else
{
tmpSalesTable.clear();
tmpSalesTable.SalesId_2 = salesLine.SalesId;
tmpSalesTable.ItemId_2 = salesLine.ItemId;
tmpSalesTable.CustAccount_2 = salesLine.CustAccount;
tmpSalesTable.Qty_2 = salesLine.QtyOrdered;
tmpSalesTable.insert();
}
}
}
}


Override the fetch() method on the report. Call the populateTmpTable and then send line after line to the report design.

public boolean fetch()
{
;
element.populateTmpTable();

while select tmpSalesTable
{
element.send(tmpSalesTable);
}

return true;
}


Create a new section group for TmpSalesTable2Col and a Body. Put the fields from the table in the body or use a FiledGroup. If necessary add a Sum section, header etc. The report should look like this

[[Image:Report2Col.PNG]]

[[Category:Report development]]


Источник: http://www.axaptapedia.com/Multi_Column
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axaptapedia: Editor scripts FormatToColumnLayout Blog bot DAX Blogs 0 24.01.2009 22:05
axaptapedia: Load Web Documents Blog bot DAX Blogs 1 03.01.2009 23:50
axcoder: AxPath is supported by axaptapedia Blog bot DAX Blogs 0 11.05.2007 10:00

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 12:14.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.