Skip to main content

Multiple Grid Selections 2

1. Yeni bir form yapın. (Ör : ATOL_CustTableSelection)
2. Formunuzun dataSource düğümüne formda göstermek istediğiniz tabloyu sürükleyip bırakın. (Ör CustTable)
3. Formunuzun metodlarını alttaki gibi düzenleyin.

1//classDeclaration metodunu değiştirin
2
3public class FormRun extends ObjectRun
4{
5Map markedLines;
6}


1//init metodunu değiştirin
2
3public void init()
4{
5super();
6
7this.initMarkedLines();
8}

1//yeni bir metod ekleyin
2void initMarkedLines()
3{
4;
5markedLines = new Map(Types::Int64, Types::String);
6}

01//yeni bir metod ekleyin
02void showSelected()
03
04{
05MapEnumerator mapEnumerator;
06RecID recId;
07int lineNum = 1;
08CustTable custTableLocal;
09;
10mapEnumerator = markedLines.getEnumerator();
11
12while (mapEnumerator.moveNext())
13{
14recId = mapEnumerator.currentKey();
15custTableLocal = CustTable::findRecId(recId, true);
16
17if(custTableLocal)
18{
19info(strFmt("%1 : %2 - %3",
20lineNum,
21custTableLocal.AccountNum,
22custTableLocal.Name));
23
24lineNum++;
25}
26}
27
28if(lineNum == 1)
29warning("@SYS34359");
30}

01//yeni bir metod ekleyin
02void markAll()
03{
04Query q = CustTable_ds.queryRun().query();
05QueryRun qr = new QueryRun(q);
06CustTable custTableLocal;
07;
08while(qr.next())
09{
10custTableLocal = qr.get(tableNum(CustTable));
11CustTable_ds.editMark(true, custTableLocal, true);
12}
13
14CustTable_ds.research(true);
15}

1//yeni bir metod ekleyin
2void clearSelections()
3{
4this.initMarkedLines();
5
6CustTable_ds.research(true);
7}

4. Formunuzun CustTable datasource’una alttaki gibi bir edit metodu ekleyin.

01edit boolean editMark( boolean _set,
02CustTable _custTable,
03boolean _mark)
04{;
05if (_set)
06{
07if (!_mark)
08{
09if (markedLines.exists(_custTable.RecId))
10{
11markedLines.remove(_custTable.RecId);
12}
13}
14else
15{
16markedLines.insert(
17_custTable.RecId,
18_custTable.AccountNum);
19}
20}
21return markedLines.exists(_custTable.RecId);
22}

5. Formunuzun Design düğümüne bir Grid ekleyin.
6. Formda göstermek istediğiniz tüm alanları ve edit metodunuzu formdaki giride sürükleyip bırakın.
7. Formunuza görüntüdeki gibi butonlar ekleyin. Ve formunuzun genel görünümünün görüntüdeki gibi olduğundan emin olun.

8. Butonların clicked metodlarından ilgili metodları çağırın. Örneğin ButtonMarkAll.clicked metodu alttaki gibi görünmeli :

1void clicked()
2{
3super();
4element.markAll();
5}

9. Formunuzu açıp test edin.

Dikkat : Bu yazıda daha önce değinmedimiz pek çok yapıyı zorunlu olarak kullandık.
Anlamadığınız konuları özellikle sorarsanız ayırca makale yazarak açıklayabilirim.
Bu kodları tam olarak anlamadan canlı ortamda kullanmayın.
Emre TÜFEKÇİ

Popular posts from this blog

Mark All for Open Cust Trans and Open Vend Trans

We have situations where there are lots of open transactions that need to be settled against each other. This can be the case if auto settlement is turned off. One solution is to add a "Mark All" button to the custOpenTrans or vendOpenTrans forms. This button "checks" the mark checkbox on every line. The user can then uncheck several lines if needed and Update to settle the lines. The code below is an example of what we used on the open vendor transaction screen. The code is very similar on the AR side. One note: I used vendTable.AccountNum in the code below. That should be generalized to work with any buffer that is passed into the open trans form. void customMarkAll() { VendTransOpen localVendTransOpen; VendTrans localVendTrans; container conSum; int linesProcessed; ; //show wait cursor startLengthyOperation(); element.lock(); //remove all prior markings specOffsetVoucher.deleteSpe...

Print Report in Microsoft Dynamics AX 2009 through X++

I am trying to print sales confirmation report on a button click which I have added on Sales Order Detail form in Microsoft Dynamics AX 2009. On click event of that button, I have written following code: void clicked() {     Args                args;     ReportRun           reportRun;     SalesFormLetter     salesFormLetter;     PrintJobSettings    printJobSettings;     CustConfirmJour     custConfirmJour;     RecordSortedList    list                = new RecordSortedList(55);     SalesTable          salesTableUpdate;     ;     SELEC...

Creating Free Text Invoice through X++ code

Job: Calling class from job to run the class public void freeTextInvoicePostTestJob() { Dialog dialog; DialogField dlgCustAcc; DialogGroup dialogPeriodLengthGroup, dialogPeriodLengthGroup1; DialogField dlgLedgerAcc; ; dialog = new Dialog("Free-Text Invoice"); dialogPeriodLengthGroup1 = dialog.addGroup('Cust Table'); dlgCustAcc = dialog.addField(typeid(CustAccount)); dialogPeriodLengthGroup = dialog.addGroup('Ledger Table'); dlgLedgerAcc = dialog.addField(typeid(LedgerAccount)); if(dialog.run()) { if(dlgCustAcc.value() && dlgLedgerAcc.value() != '') FreeTxtInvoiceCreatePost::main(dlgCustAcc.value(), dlgLedgerAcc.value()); else throw error(strfmt("Either CustAccount or LedgerAccount info is missing.")); } } Class: Which creates the free text invoice class FreeTxtInvoiceCreatePost { } static void main(CustAccount _custAccount, LedgerAccount _ledgerAccount) { CustInvoiceTable custInvoiceTable; ...