How to get the number of the selected records in a grid

maria_iva81
Member Posts: 39
Hi there does any body know how to get the number of selected records in a grid.
For example CustTransOpen_ds.mark() does not return it. Please help. I would like to check if the number is > 1 so that i can throw error
For example CustTransOpen_ds.mark() does not return it. Please help. I would like to check if the number is > 1 so that i can throw error
0
Comments
-
A solutions is this:
int i;
smmMailings smmMailings1;
;
super();
smmMAilings1 = smmMailings_ds.getFirst(true);
while (smmMailings1)
{
i++;
smmMailings1 = smmMailings_ds.getNext();
}
info(int2str(i));
Best regards,
CiprianKind regards,
Ciprian Dudau
Axapta Developer0 -
I have a checkbox infront of every line in the datagrid.I would like to get the number of the lines that have marked checkboxes..This is the code i use to see their number but i is always equal to 1,,,
for (CustTransOpen = CustTransOpen_ds.getFirst(true) ? CustTransOpen_ds.getFirst(true) :
CustTransOpen_ds.cursor(); CustTransOpen; CustTransOpen = CustTransOpen_ds.getnext())
{
i ++;
}
info(int2str(i));
I have now idea how else to do it..Please help0 -
Hi,
The code is always returning 1 because it is looking only for selected records (meaning highlighted while holding Shift/Ctrl).
For the selection you are trying to implement there is no Axapta trick... just try to see what the check box represents. Is it a field, a display method; does it belongs to the same datasource as the other fields or not etc.
E.g.: If a field, perform a query against the datasource by maintaining the same filters as in the form and in addition use another filter (range) for the checkbox field with the value NoYes::Yes.
Then you should count the number of recs in this query. Axapta provides a class method to ease this operation: SysQuery::countTotal(queryRun).
Please let me know if you have still have problems, but be more specific with the problem details. A checkbox can mean many things..Kind regards,
Ciprian Dudau
Axapta Developer0 -
Thanks for helping me again
This checkbox represents a datamethod in the form CustOpenTrans called markTrans(this a method for the datasource CustTransOpen). I would like to write something like:
select count(recid) from CustTransOpen where CustTransOpen.checkboxvalue == NoYes::Yes but i don't know how to get the value of the checkbox since it's not a field, but a method for the datasource.0 -
Hi Maria,
Should I understand that the code is for the Open transactions editing (CustTransOpen) form?
ONLY if Yes, you can successfully use this code (otherwise please let me know what is the name of the form; however you can still use the code as reference):
CustTransOpen testCustTransOpen;
CustTrans testCustTrans;
int i;
;
while select testCustTransOpen
WHERE testCustTransOpen.AccountNum==CustTransOpen.AccountNum
JOIN testCustTrans
WHERE testCustTransOpen.AccountNum==testCustTrans.AccountNum &&
testCustTransOpen.RefRecId==testCustTrans.RecId
{
if (specOffsetVoucher.checkExist(testCustTransOpen.recID) &&
!specOffsetVoucher.isMarkedElsewhere(testCustTransOpen.RecId, common.RecId))
{
i++;
info (testCustTrans.Voucher);
}
}
if (i>1)
{
throw error("There are more than one transactions marked!");
}
else
{
info("Transactions are marked correctly.");
}Kind regards,
Ciprian Dudau
Axapta Developer0 -
Thanks a million this is what i needed it's just such a wierd way to get the count of the lines with the checked checkboxes...If you can give smo details about the purpose of this class and its methods , i mean specOffsetVoucher, cause i didn't find anything in the help system. Once again thanks for helping me0
-
Glad to be of help. Regarding the class I really don't know much. I deducted the conditions from the code in MarkedTrans() method
. It is obvious that it is responsible of handling the logic of marking customer open transactions. To find much see the methods in the class / use the Debugger while running the form. You can also use the Code explorer add-in tool to browse the code of an object.
Regarding the code documenting, you probably noticed that very few classes/methods have documentation (mostly the system classes). That's why you have to learn directly from code... :roll:
Best regards,
CiprianKind regards,
Ciprian Dudau
Axapta Developer0 -
Hi there
After limiting the number of checked lines to 1 the next step is to get this line and pass it to another form. I made a display menu item and in its click method i use args class to pass it. The problem is that i write : args.parm(CustTrans.Invoice); which is not correct
(beacause it doesn't give the selected record)but i don't know what criteria to use to get this very invoice that has its checkbox checked....Please help
0 -
IF you only need to pass one record to other form then you can use the Args.record. not sure the corrected syntax but my guess is as follow
Args.Record(CustTrans);
Or you can store all the recid that you wanted in a container and pass it to other form
Args.Parm(container); // please correct me if i'm wrong as i very very new to axapta.
Or you can pass the current FormDataSource to other Form and from there you can use the sample codes giving to you by Mugur to retrieve those records that you wanted.
hope my contribution can help or make sense. :roll:0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions